zend-framework2

Routing in Zend Framework 2

限于喜欢 提交于 2019-12-01 16:41:17
I'm trying to do some routing in Zend Framework 2, but it's not working. The basics of the skeleton application are working, so I added a new module called User and the following code in the file \module\User\config\module.config.php 'controllers' => array( 'invokables' => array( 'User\Controller\User' => 'User\Controller\UserController', ), ), 'router' => array( 'routes' => array( 'login' => array( 'type' => 'Literal', 'options' => array( 'route' => '/login', 'defaults' => array( '__NAMESPACE__' => 'User\Controller', 'controller' => 'User', 'action' => 'login', ), ), ), 'user_create' => array

How to implement beberlei doctrine extensions in zend framework 2

自作多情 提交于 2019-12-01 16:37:33
问题 i dont know how to integrate the beberlei doctrine-extensions: https://github.com/beberlei/DoctrineExtensions in Zend Framework 2 with Doctrine Module. I installed it with composer: "beberlei/DoctrineExtensions": "dev-master" I tried in my module.config.php from th application module: 'doctrine' => array( 'driver' => array( __NAMESPACE__ .'_driver' => array( 'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', 'cache' => 'array', 'paths' => array(__DIR__ . '/../src/'.__NAMESPACE__.'

Get the posted data from Form in Zend Framework 2

我怕爱的太早我们不能终老 提交于 2019-12-01 16:34:21
问题 Im new to Zend Framework, so asking a basic question. I want to get the posted data, in general from one field in a form, I wanted to get the data for debugging purposes. For example I have a form with fields like username, age and so on. In my controller in addAction(), I want to fetch the username, store it in a variable and use it for debugging purposes. I hope I made it clear. In case if my question is unclear then please do let me know. Thanks 回答1: You're not very clear so I suggets a

Doctrine One-To-Many Relationship Won't Save - Integrity Constraint Violation

大憨熊 提交于 2019-12-01 16:18:22
I'm attempting to use Doctrine ORM Associations. I've read several tutorials and the online docs, but it's not working, and I'm honestly not sure what I'm doing wrong here. Seems like my experiments with Doctrine are pretty hit or miss. Any assistance would be appreciated. I'd like to have a User entity and UserHistory entity, which has multiple rows for a single User. That to me sounds like One-To-Many. I don't necessarily need it to be bidirectional. The problem I'm having is adding a history item to a user results in an error when the user is saved, because the user_id column is not set in

Zend Framework 2 Autoload Third Party library using composer

别来无恙 提交于 2019-12-01 14:30:19
I am trying to use composer to autoload a third party library into my ZF2 application - specifically Google api. I followed the answer in this post on SO, edited my composer.json "autoload": { "psr-0": {"Googleanalytics\\": "vendor/google-api-php-client/src/"} } and ran update. I can see the entry in composer/autoload_namespaces.php 'Googleanalytics\\' => array($vendorDir . '/google-api-php-client/src'), but i still get a fatal error class not found when trying to instantiate a class in that directory (Google_Client.php). Any ideas what i am missing? I am including the file in the class i am

How to show zf2 errors?

こ雲淡風輕ζ 提交于 2019-12-01 14:26:22
I've reinstall my system and now when something wrong in zf2 i cant see the error on the page only in nginx error log, the display_errors On and display_startup_errors On, in php.ini, maybe something with my php-fpm settings? And in the simple php file not in zf2 i have see the errors! You need enable the following options in your config 'view_manager' => array( 'display_not_found_reason' => true, 'display_exceptions' => true, ) Remember turn off this in a production environment ini_set('display_errors', true); in my index.php now show me the errors Zend framework 2 will merge configs from all

Zend Framework 2 - Hydrator strategy not responding and hydrating

我是研究僧i 提交于 2019-12-01 14:23:18
I implemented basically this strategy . The main difference is (I guess) that I use Doctrine2 . The constructor class is called (a test echo is printed) but the two functions extract() and hydrate() are not. I added the strategy as follows: $hydrator = new DoctrineEntity($entityManager); $hydrator->getHydrator()->addStrategy('my_attribute', new MyHydrationStrategy()); $form->setHydrator($hydrator); A kind-of similar issue was posted here . Maybe the problem is in the way how I add this strategy. But I honestly don't know... Would be great if somebody could give me a hint what I'm doing wrong.

ReflectionException is thrown when mapping entities in Doctrine from different databases

前提是你 提交于 2019-12-01 14:13:56
I'm trying to use Doctrine 2 in a ZF2 application which contains two modules, each with its own database. I need to use cross-database joins so that I can associate entities from one module with entities in another. Here's a UML diagram of the setup. I've tried using this in my first entity (I've removed irrelevant parameters and use statements): namespace Client\Entity; /** * A website. * * @ORM\Entity * @ORM\Table(name="users.website") * ... * @property $server */ class Website extends BaseEntity { // Other class vars ... /** * @ORM\ManyToOne(targetEntity="Server\Entity\Server", inversedBy=

Set & Access Variables in error Page ZF2

隐身守侯 提交于 2019-12-01 13:03:41
class FrontController extends AbstractActionController { public function indexAction() { $this->layout()->setting_data = $this->getSetting()->getSettingContent(1); return array(); } } public function getSetting() { return $this->getServiceLocator()->get('Front/Model/Setting'); } class Setting extends AbstractTableGateway { public function __construct($adapter) { $this->table = 'setting'; $this->adapter = $adapter; } public function fetchAll() { return $this->select(); } public function getSettingContent($id){ $id = (int) $id; $rowset = $this->select(array('id'=>$id)); if (!$row = $rowset-

ZF2 Doctrine 2 ObjectSelect with distinct on field

做~自己de王妃 提交于 2019-12-01 12:36:16
to populate my form I use the fieldset approach. For one given form field I will use a select and the options are coming directly from an entity like this: $this->add( array( 'type' => 'DoctrineModule\Form\Element\ObjectSelect', 'name' => 'city', 'options' => array( 'label' => 'City: ', 'object_manager' => $this->_om, 'target_class' => 'Hotbed\Entity\AllAdresses', 'property' => 'city', 'is_method' => true, 'find_method' => array( 'name' => 'findBy', 'params' => array( 'criteria' => array('postal_code' => $postalCode), 'orderBy' => array('city' => 'ASC'), ), ), ), 'attributes' => array( 'class'