zend-framework3

ZF3 Development Mode VS Production Mode

寵の児 提交于 2019-12-11 00:26:45
问题 I use ZF3 and code in the development mode. I configured it like the tutorial suggests: composer development-enable So everything works fine if this mode is enabled. If I disable it I get a database connection error, like this one: Connect Error: SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'xyz' I still work on the same computer. So what error it might be? The main topic would be, how is the right way to change between development and production, does the composer

Zend 3 Argument 1 passed to Application\Controller\IndexController::__construct() must be an instance of , none given,

隐身守侯 提交于 2019-12-10 20:12:28
问题 This configuration works on my local install, but not on remote site. ExampleManager.php <?php namespace Application\Service; use Application\Entity\SomeTable; class ExampleManager { /** * Entity manager. * @var Doctrine\ORM\EntityManager */ private $entityManager; public function __construct($entityManager) { $this->entityManager = $entityManager; } ExampleManagerFactory.php <?php namespace Application\Service\Factory; use Interop\Container\ContainerInterface; use Zend\ServiceManager\Factory

ZF3 session timeout issue

淺唱寂寞╮ 提交于 2019-12-10 17:48:32
问题 I have been facing issue related to Session timeout using Zend Framework 3. Session expired within 5-10 min. I had used the default code for the session, which Zf3 skeleton provides in global.php as below. // Session configuration. 'session_config' => [ 'cookie_lifetime' => 60*60*1, // Session cookie will expire in 1 hour. 'gc_maxlifetime' => 60*60*1, // Store session data on server maximum for 1 hour. ], // Session manager configuration. 'session_manager' => [ 'validators' => [ RemoteAddr:

How to execute Zend Framework 3 action with zf-console?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 07:06:15
问题 I want to execute ZF3 action with zf-console. I can do this using zend-mvc-console module and it works fine. For example. Application/config/module.config.php: 'console' => [ 'router' => [ 'routes' => [ 'cronroute' => [ 'options' => [ 'route' => 'sync', 'defaults' => [ 'controller' => Controller\ConsoleController::class, 'action' => 'syncEvents' ] ] ] ] ] ], Application/src/Controller/ConsoleController.php class ConsoleController extends AbstractActionController { /** * Entity manager. * @var

zf3 getting different view in an action

佐手、 提交于 2019-12-08 15:22:29
问题 in zf2 i was doing this, $view = 'application/use/view'; $htmlString = $this->getServiceLocator() ->get('viewmanager') ->getRenderer() ->render( $view, array( 'institute' => $institute, 'gender' => $gender ) ); but there is no direct getServiceLocator method in zf3 how can i do this in zf3,via factory So far i have done this: in my factory public function __invoke(ContainerInterface $container, $requestedName, Array $options = null) { $auth = $container->get('doctrine.authenticationservice

How get basepath from model or helper en Zend Framework 3

喜欢而已 提交于 2019-12-08 11:17:28
问题 I recently decided to use Zend Framework 3 after 3 years of using Zend Framework 1. This decision has given me headaches, Zend 3 instead of making things easier made things more difficult. In Zend 1, I customize the url for the selected template in the database as follows: public function getUrl(string $file = '') { if($this->_helperBaseUrl === null) { $this->_helperBaseUrl = new Zend_View_Helper_BaseUrl(); } return $this->_helperBaseUrl->baseUrl($file); } public function getSkinUrl(string

How to attach event listener via configuration instead of module bootstrap?

杀马特。学长 韩版系。学妹 提交于 2019-12-08 05:59:34
问题 In ZF3 you would normally attach your event listener for the MvcEvent 's in your module's Module.php like so: <?php namespace MyModule; class Module { public function onBootstrap(MvcEvent $event) { $eventManager = $event->getApplication()->getEventManager(); $eventManager->attach(MvcEvent::EVENT_DISPATCH, function(MvcEvent $event) { // Do someting... }); } } Now there are two typical situations where your Module.php can grow big: Your module has to handle multiple (or even all) MvcEvent 's

How to get matched route name in View - Zend Expressive

大憨熊 提交于 2019-12-08 02:16:59
问题 I know that I can generate URL passing the route name <?php echo $this->url('route-name') #in view file ?> But can I get information in opposite direction? From current URL/URI, I need to get route name. Real case is: I have layout.phtml where is the top menu (html). Current link in the menu need to be marked with css class. So, example what I need is: <?php // in layout.phtml file $index_css = $this->getRouteName() == 'home-page' ? 'active' : 'none'; $about_css = $this->getRouteName() ==

ZF2/3 Load Modules from Database

杀马特。学长 韩版系。学妹 提交于 2019-12-07 02:59:27
I would like to know if there is a way to load modules from a database table in zend framework 2 preferable 3? I want to be able to dynamically disable or enable modules based on a status column inside a database table I'm pretty sure you can accomplish this by attaching listener to some of ModuleManager events. There are docs for v3 https://docs.zendframework.com/zend-modulemanager/module-manager/ and v2 https://framework.zend.com/manual/2.1/en/modules/zend.module-manager.module-manager.html And don't forget autoloading for v3 By reading your question tom_cruz , I realize that I have exactly

How to attach event listener via configuration instead of module bootstrap?

南楼画角 提交于 2019-12-06 15:50:38
In ZF3 you would normally attach your event listener for the MvcEvent 's in your module's Module.php like so: <?php namespace MyModule; class Module { public function onBootstrap(MvcEvent $event) { $eventManager = $event->getApplication()->getEventManager(); $eventManager->attach(MvcEvent::EVENT_DISPATCH, function(MvcEvent $event) { // Do someting... }); } } Now there are two typical situations where your Module.php can grow big: Your module has to handle multiple (or even all) MvcEvent 's and maybe even treat them in different ways. Your module has to perform multiple actions on a single