PHP Web Server
Some common ones:
//Module.php | |
<?php | |
namespace VendorName\LibraryName; | |
class Module | |
{ | |
public function getAutoloaderConfig() | |
{ | |
return array( |
<?php | |
// Hostname route | |
'front-ent' => array( | |
'type' => 'Hostname', | |
'options' => array( | |
'route' => ':subdomain.' . BASE_DOMAIN, | |
'constrains' => [ | |
'subdomain' => '[a-zA-Z0-9\-]+', | |
], | |
'defaults' => array( |
<?php | |
'logger1' => function ($sm) { | |
$logger = new Zend\Log\Logger(); | |
$writer = new Zend\Log\Writer\Stream(APP_PATH . '/data/logs/app.log'); | |
$formatter = new Zend\Log\Formatter\Simple( | |
'%timestamp% %priorityName% (%priority%): %message%', | |
'd.m.Y H:i:s'); | |
$writer->setFormatter($formatter); | |
$logger->addWriter($writer); |
<?php | |
'factories' => array( | |
'My\Service\BankAccount' => function($serviceManager) { | |
$bankAccountService = new My\Service\BankAccount($serviceManager->get('Doctrine\ORM\EntityManager')->getRepository('My\Entity\BankAccount')); | |
return $bankAccountService; | |
}, | |
), |
<?php | |
/* existing stuffs */ | |
class Module | |
{ | |
/* more existing stuffs */ | |
public function getServiceConfig() | |
{ | |
return array( |
<?php | |
/** | |
* This makes our life easier when dealing with paths. Everything is relative | |
* to the application root now. | |
*/ | |
chdir(dirname(__DIR__)); | |
// Setup autoloading | |
require 'init_autoloader.php'; |
<?php | |
public function onBootstrap(MvcEvent $e) | |
{ | |
$em = $e->getApplication()->getEventManager(); | |
$em->attach('dispatch', array($this, 'chooseLayout')); | |
} | |
public function chooseLayout(MvcEvent $e) | |
{ | |
$matches = $e->getRouteMatch(); |
<?php | |
$form = new Form(); | |
$form->setAttribute('method', 'post'); | |
$fieldset1 = new Fieldset('user'); | |
$fieldset1->setOptions(array( | |
'use_as_base_fieldset' => true | |
)); | |