This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Run docker in interactive mode | |
| docker run -it -p 8082:8082 -v ${PWD}:/app php:latest bash | |
| ## Run build-in server with mounted sources | |
| php -S 0.0.0.0:8082 public/index.php | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class MailService | |
| { | |
| private function validateString(String $input, int $minSize = 10): bool | |
| { | |
| return strlen($input) >= $minSize; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace <ModuleNamespace>\Model\Logger\Handler; | |
| use Magento\Framework\Logger\Handler\Base; | |
| use Monolog\Logger; | |
| class ExceptionFile extends Base | |
| { | |
| protected $fileName = 'var/log/my.log'; | |
| protected $loggerType = Logger::CRITICAL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker exec -it php bash -c "stty cols $COLUMNS rows $LINES && bash"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); | |
| /** Boolean attribute */ | |
| $eavSetup->addAttribute(Category::ENTITY, 'have_engine', | |
| [ | |
| 'type' => 'int', | |
| 'label' => 'Have engine', | |
| 'input' => 'boolean', | |
| 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', | |
| 'visible' => true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ brew install [email protected] | |
| $ brew install [email protected] | |
| $ brew install [email protected] | |
| $ brew install [email protected] | |
| /usr/local/etc/php/5.6/php.ini | |
| /usr/local/etc/php/7.0/php.ini | |
| /usr/local/etc/php/7.1/php.ini | |
| /usr/local/etc/php/7.2/php.ini |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $installer->getConnection()->getTable('<TableName>') | |
| ->addForeignKey( | |
| $installer->getFkName('<ChildTable>', 'entity_id', '<ParentTable>', 'entity_id'), | |
| 'entity_id', | |
| $installer->getTable('<ParentTable>'), | |
| 'entity_id', | |
| \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider | |
| { | |
| public function getData() | |
| { | |
| $typeId = intval($this->request->getParam({field_name_for_filter}), 10); | |
| if ($typeId){ | |
| $filter = new \Magento\Framework\Api\Filter(); | |
| $filter->setField({field_name_for_filter_in_database})->setValue($typeId)->setConditionType('eq'); | |
| $this->addFilter($filter); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ALTER TABLE tablename ADD created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL; | |
| ALTER TABLE tablename ADD updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $query = "SELECT * FROM table WHERE name = :name"; | |
| $bindParams = [":name" => $value]; | |
| $query = str_replace( | |
| array_keys($bindParams), | |
| array_map(function($a){ return '"' . addslashes($a) . '"';}, array_values($bindParams)), | |
| $query | |
| ); |
NewerOlder