zend-framework2

ZF2: autoloading libraries without namespaces

纵然是瞬间 提交于 2019-12-01 07:32:56
Previously I have only been using third party libraries that use namespaces together with Zend Framework 2. Now I need to use a library that does not use namespaces, and I cannot seem to make it work. I installed it via Composer, and it is installed fine into the vendor directory. I am trying to use it as follows: $obj = new \SEOstats(); The result is a fatal error indicating that the class could not be found. I have tried to manually configure the StandardAutoloader , but so far without any luck. I thought that the autoloading would be done for me automatically when installing through

Dependency management in Zend Framework 2 MVC applications

房东的猫 提交于 2019-12-01 07:12:41
As the ServiceLocatorAwareInterface will likely be removed from the AbstractController in ZF3 , dependencies should instead be passed via the constructor or via setter methods. With this in mind, consider the use case of a user or site controller with actions such as register, activate account, login, logout, etc. At a minimum, this would require a UserService and 2 forms. Add a few more related actions (remote authentication, linking of accounts, etc.) and you end up with 4 or 5 forms. Passing all these dependencies via the constructor would be messy at best, and more importantly, only 1 form

Handling dependencies in Zend Framework 2 Forms

半城伤御伤魂 提交于 2019-12-01 06:37:13
I am trying to build a form in ZF2. The problem comes when I want to populate the options array of a Select input element from a database table. A response to this question Zend FrameWork 2 Get ServiceLocator In Form and populate a drop down list by @timdev pointed me to the ZF2 docs where the 'correct' method is described. I followed this carefully but I suspect that they must have left obvious code out assuming I could fill in the gaps as I cannot get it to work. Can anyone see what I am doing wrong? I start with a form to which I add a fieldset: namespace Ctmm\Form; use Zend\Form\Form;

ZF2 skeleton application is throwing 500 error

耗尽温柔 提交于 2019-12-01 06:36:19
问题 When trying to deploy the skeleton application using the following commands: git clone git://github.com/zendframework/ZendSkeletonApplication.git cd ZendSkeletonApplication php composer.phar self-update php composer.phar install I get the following error: PHP Fatal error: Uncaught exception 'Zend\\ServiceManager\\Exception\\InvalidArgumentException' with message 'Provided abstract factory must be the class name of an abstract factory or an instance of an AbstractFactoryInterface.' in /home

How to get the controller name, action name in Zend Framework 2

点点圈 提交于 2019-12-01 06:14:53
问题 I have a default module in Zend Framework 2: namespace Application\Controller; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; class IndexController extends AbstractActionController { public function indexAction() { return new ViewModel(); } } How can I get the name of the current controller or action name ... and pass it to the view and/or layout? Have to say that I am just starting with the ZF2 framework. 回答1: Try as below for ZF2 $this->getEvent()-

How to use DoctrineModule\Validator\NoObjectExists in edit forms - Zend Framework 2 & Doctrine 2

北战南征 提交于 2019-12-01 06:06:37
问题 What is the most effective way to use DoctrineModule\Validator\NoObjectExists validator in a Zend Form that is used for editing also? Because when I use the same Form for saving edited values, this validates the Object existence and flags form is invalid. 回答1: Few weeks ago I resolved the same problem using a helper method in my custom filter. I am not sure if this is the correct approach but it works. Write a custom inputfilter extending Zend\InputFilter\InputFilter . Add your generic

Configure multi DB connections on ZF2

一世执手 提交于 2019-12-01 05:56:57
I'm actualy a beginner in ZF2 I managed to use multiple BDD on the same application and it works. (I'm talking about this : configure multiple databases in zf2 ). Though, I'd have a little question... Is it ok to declare my custom factory in global.php ? (in the service_manager thing). Or do I need to declare it inside each module ? (in module.php) Declaring it into global.php actualy works, but I was wondering if it's not breaking the spirit of the framework or something... Thanks for your time ! Tounu Store your connection settings in a local config: config/autoload/local.php this is in case

How to install Zend Framework 2 Tool with composer

允我心安 提交于 2019-12-01 05:19:37
I can't figure out how to run zf.php (Zend Framework 2 Tool) when bootstrapped with composer. First I bootstrap composer and zftool according to the documentation: $ mkdir tmp && cd tmp $ curl -s https://getcomposer.org/installer | php $ ./composer.phar require zendframework/zftool:dev-master This works fine so far. But when I try to run zf.php, I get errors: $ vendor/zendframework/zftool/zf.php PHP Warning: require_once(/Users/seb/tmp/vendor/zendframework/zftool/vendor/autoload.php): failed to open stream: No such file or directory in /Users/seb/tmp/vendor/zendframework/zftool/zf.php on line

How to extend the ZF2 skeleton application - entities with foreign keys

こ雲淡風輕ζ 提交于 2019-12-01 05:07:14
问题 My ZF2 skeleton application works fine as per the Zend user guide. But now I'm running in circles trying to extend the application so that an album's artist isn't a string anymore but a foreign key of the artist table in my db. I've created all the necessary models, controllers, views to create, edit and view artists, which also works fine. But how do I combine the two so that my list of albums shows the artist's name? Do I use a hydrator strategy as suggested here? If so, how do I implement

ZF2: autoloading libraries without namespaces

◇◆丶佛笑我妖孽 提交于 2019-12-01 04:55:24
问题 Previously I have only been using third party libraries that use namespaces together with Zend Framework 2. Now I need to use a library that does not use namespaces, and I cannot seem to make it work. I installed it via Composer, and it is installed fine into the vendor directory. I am trying to use it as follows: $obj = new \SEOstats(); The result is a fatal error indicating that the class could not be found. I have tried to manually configure the StandardAutoloader , but so far without any