zend-framework2

Configuring class alias for using with Zend\Di\Di

主宰稳场 提交于 2019-12-11 04:19:06
问题 I have a logger class (Application\Debug\Logger) for logging various debug messages from whole application to log files. And I would like to get instance of that class using simple alias 'logger'. So I try to configure Zend\Di\Di, so that I could do something like this in, for example, module controller or another application components: $di = new \Zend\Di\Di(); $logger = $di->get('logger'); //$logger should be Application\Debug\Logger instance... To achieve this, I have this in Application

Many-to-Many relationship in Zend 2 Framework

梦想的初衷 提交于 2019-12-11 04:18:34
问题 I use the Zend 2 Framework to build my web application. I implemented my database table models by this tutorial: http://framework.zend.com/manual/2.1/en/user-guide/database-and-models.html I have a many-to-many relationship between two models in my database. To get data from them I googled and found this link: http://mattmccormick.ca/2010/04/24/how-to-easily-create-models-and-table-relationships-in-zend-framework/ The problem is that all the table models extends from Zend_Db_Table_Abstract in

ZF2 Doctrine: When to flush ObjectManager

China☆狼群 提交于 2019-12-11 04:06:51
问题 when is the best "time" to flush the Entity/Object-manager? Should it be after every persist operation? Or should it be run once on e.g. postDispatch? 回答1: Running it after every persist is an antipattern actually. Ideally, you should run it once at the end of the request. I would not put it in a postDispatch handler, because that means it will run after every request, and that is going to be costly performance wise on, for example, list pages, where you list entities with many relations,

zend framework 2 in a subdirectory

放肆的年华 提交于 2019-12-11 03:53:55
问题 I want to put zend framework 2 in a subfolder. The skeleton app works out of the box by putting the whole app in a sub-directory and then using domain.com/path/to/public/index.php, but I want to avoid having the long url and I don't want everything else to be in my DocumentRoot other than my public folder. I thought about having multiple modules, but I have other types of applications under my domain and can't have the public folder be the DocumentRoot nor do I want to recreate everything I

Zend\Crypt\Password\BCrypt verify method

跟風遠走 提交于 2019-12-11 03:50:44
问题 I am using Zend\Crypt\Password\Bcrypt for storing passwords encrypted in the database. But now I looked a bit closer and I don't seem to understand the verify method of this class: /** * Verify if a password is correct against a hash value * * @param string $password * @param string $hash * @throws Exception\RuntimeException when the hash is unable to be processed * @return bool */ public function verify($password, $hash) { $result = crypt($password, $hash); return Utils::compareStrings($hash

Doctrine 2 ORM Zend 2 Form Many to Many Example

房东的猫 提交于 2019-12-11 03:42:30
问题 Anyone have a good and complete example for many to many relation using ZF2 and Doctrine 2, especially when using ObjectMultiCheckBox ? I found this tutorial - https://github.com/doctrine/DoctrineModule/blob/master/docs/hydrator.md but it don't explain how to do a many to many relation. 回答1: K so I figured out how todo this eventually after realizing the hydrator wasn't binding associations and I had to create the link. I'm going to put a full blog post up explaining it but in case you're

Zend Framework 2 - Annotation forms and Doctrine2 - Catchable fatal error - ObjectManager

為{幸葍}努か 提交于 2019-12-11 03:34:10
问题 I'm using Zend, Doctrine2.1 and AnnotationForms. My entity looks like this: /** * @ORM\Entity * @ORM\Table(name="myentity") * @Form\Name("myentity") * @Form\Attributes({ "class": "form-horizontal" }) * @Form\Hydrator("\DoctrineModule\Stdlib\Hydrator\DoctrineObject") */ class MyEntity { ... } When using this DoctrineObject I get the following error: Catchable fatal error: Argument 1 passed to DoctrineModule\Stdlib\Hydrator\DoctrineObject::__construct() must be an instance of Doctrine\Common

Disable some options select in Zend Framework 2

 ̄綄美尐妖づ 提交于 2019-12-11 03:33:30
问题 I would disable some option's select in Zend Framework 2. I have a select about spoken languages, when the user save a spoken language, I would disable it because he can't save again the same language. inside LanguageForm.php $this->add(array( 'name' => 'languages', 'attributes' => array ( 'class' => 'form-control', ), 'type' => 'select', 'options' => array( 'label' => 'Languages', 'empty_option' => 'Select spoken languages', 'value_options' => array( 1 => 'English', 2 => 'Spanish', 3 =>

Trouble with authentication in vk.com with zend_oauth

女生的网名这么多〃 提交于 2019-12-11 03:14:24
问题 Trouble with authentication in vk.com with zend_oauth Message: Error in HTTP request: Unable to enable crypto on TCP connection oauth.vk.com: make sure the "sslcafile" or "sslcapath" option are properly set for the environment. Help me please 回答1: You need to use curl as adapter and turn off ssl certificate checks: $adapter = new \Zend\Http\Client\Adapter\Curl(); $adapter = $adapter->setCurlOption(CURLOPT_SSL_VERIFYHOST, false); $adapter = $adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, false

ExceptionStrategy doesn't work with JsonStrategy

谁说我不能喝 提交于 2019-12-11 03:06:08
问题 I have an issue which was reported here (http://framework.zend.com/issues/browse/ZF2-379?page=com.atlassian.streams.streams-jira-plugin:activity-stream-issue-tab#issue-tabs). There is a solution, but I have no idea where to implement that. Anyone can help? Regards, 回答1: Here's code for a JsonExceptionStrategy - put it somewhere, like in a module. namespace YourNamespace; use Zend\EventManager\EventManagerInterface; use Zend\Mvc\Application; use Zend\Mvc\View\Http\ExceptionStrategy; use Zend