zend-framework2,zend-tool , Using ZFTool in ZF2 to create new modules


Using ZFTool in ZF2 to create new modules

Question:

Tag: zend-framework2,zend-tool

I installed the ZF2 skeleton application via composer and am learning ZF2 via the book Learn ZF2 by Slavey Karadzhov. I added the zftool dependency via composer after the skeleton was installed. I'm on Windows 8.

I've been through How do you add ZFTool to an existing ZF2 project (one not created with ZFTool) which implies a requirement for application.config.php in the top level config which I have.

I've tried to create a new module via:

path/to/project> php vendor/bin/zf.php create module Test

Which returns:

SRC_DIR="pwd"
cd "dirname "$0""
cd "../zendframework/zftool"
BIN_TARGET="pwd/zf.php"
cd "$SRC_DIR"
"$BIN_TARGET" "[email protected]"

The above is the contents of vendor/bin/zf.php

I've seen the same question asked on other forums but lacks answers. Any help would be much appreciated.


Answer:

On Windows OS you need to run bat file:

path/to/project>vendor\bin\zf.php.bat

or if you want to use php script, run original one from library directory:

path/to/project>php vendor\zendframework\zftool\zf.php

Related:


is not null condition in zend framework 2


php,mysql,sql,zend-framework,zend-framework2
I am new to zf and I've started working with zf2, I don't find much documentation for the syntax and all. My issue is how to write is not null condition in zf2 syntax. $select->where->notEqualTo('pe_name', ''); I've written for not equal to, now I need for is not null. I...

Zend 2 redirect() module error


zend-framework2
I have made a checklogin fucntion to check $auth->getIdentity(), but i am getting the following error: Fatal error: Call to undefined method Admin\Module::redirect() in C:\xampp\websites\zend2\module\Admin\Module.php on line 51 How can i fix this? public function onBootstrap(MvcEvent $e) { $eventManager = $e->getApplication()->getEventManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); $app = $e->getParam('application'); $app->getEventManager()->attach('render',...

How to route pages using text instead of IDs?


zend-framework,zend-framework2,zend-route,zend-router
Currently, my Zend application routes using the URL: example.com/news/12 Selects the news with ID 12 to display on page. But the client wants to use only text, example: example.com/news/man-dies-after-burning-himself Does someone knows how can it be done?...

PHPUnit: Testing RestFul API with die response


php,json,api,zend-framework2,phpunit
I am trying to PHPUnit test an action in my ZF2 project. The APIs return a JSON string using die($jsonObject). This causes the PHPUnit test to stop processing and just die a JSON response. public function testStartupAction() { $this->dispatch('/api/v3/startup', "POST", array()); $this->assertJson('{"status":false,"message":"Please enter the UID","data":null}'); } assetJson method is never...

zend framework 2 controller's action arguments


zend-framework2
I had this public function in ApplicationController public function indexAction($bar) { echo $bar; return new ViewModel(); } How I can pass this argument? I've tried http://localhost/zf2/public/application/index/index?bar=foo but this not works...

Uncommon usage of form attributes in ZF2


php,zend-framework2
I'm writing a simple CMS, where on each page users can edit all its attached languages. For example, the raw $_POST input when a user submits a form, typically must look like as following: array( 'fr' => array( 'name' => 'Some name in French', 'content' => 'Some content in French'...

zend2 forms and action attribute


forms,zend-framework2
in my EditController I have indexAction : public function indexAction() { $delete = new DeleteForm(); $view = new ViewModel(array('delete' => $delete )); return $view; } and the view <?php $formDelete = $this->delete; $formDelete->prepare(); $formDelete->setAttribute('action', $this->url(NULL, array('controller'=>'Register', 'action' => 'process'))); ?> <?php echo $this->form()->openTag($formDelete);?> <div class="form-group"> <?=$this->formLabel($formDelete->get('reason')); ?>...

Ajax - doesn't change URLs


javascript,php,jquery,ajax,zend-framework2
I made the contents of the page change using Ajax, but the problem is the site url stays the same, therefore it doesn't load the page at all, just the text on it. So for example, I click on the Login link and the content changes, but the url stays...

Zend Skeleton Application album tutorial 404


php,zend-framework,zend-framework2
As far as I can see I've followed the Zend skeleton application tutorial to the letter (I actually went through it twice with the same result) but when I try to access zf2-tutorial.localhost/album I get the following error: A 404 error occurred Page not found. The requested URL could not...

Apigility - Invalid content type specified


configuration,zend-framework2,apigility
I am attempting to post login credentials to an apigility login API: $response = ClientStatic::post( 'http://www.example.com/api/login', array('email' => '[email protected]','password' => 'test'), array('Accept' => 'application/json') ); This returns the error: Cannot honor Accept type specified As far as I can tell, application/json has been whitelisted in the configs: Any ideas? My...

Zend Framework 2 routing error: resolves to invalid controller class or alias


zend-framework,routing,zend-framework2,zend-framework-mvc,zend-framework-routing
I'm trying to learn Zend Framework 2 and I have their skeleton application up and running. In order to access it I visit http://localhost:8080/. When visiting that link it displays their generic Zend page. What I want to be able to do is visit http://localhost:8080/application/test and have it bring me...

Best way to configure a Table in Module.php - Zend 2


php,zend-framework2
I am setting up my tables in module.php using the default example in zend2 tutorial, but in my project I have so much tables, so my module.php is too large. Here is my default config EXAMPLE 1: 'UsersTableGateway' => function ($sm) { $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter'); $resultSetPrototype = new ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new...

ZF2 - How do I get application config items within my model?


php,zend-framework2
In my job I am dealing with a legacy app running on ZF2. There is a model which is sending out a variety of different emails to difference addresses. The one thing they have in common is they all need to BCC to one particular address. At first, in my...

ZF 2 - Fatal Error: Call to a member function getPosts() on null


php,zend-framework2,fatal-error,member-function
I am creating a website using Zend Framework 2, and I'm using as an example the exercise from the official course of Zend Technology, Zend Framework 2: Fundamentals. I have a table called posts and I want to show the table content in my home page, ordered by id. These...

Zend 2 Translation global


php,zend-framework2
The following code works fine in a controller,how global? XXXController.php $lang = 'nl'; $loc = $this->getServiceLocator(); $translator = $this->get('translator'); $translator->addTranslationFile("phparray",'./module/admin/language/lang.array.'.$lang.'.php'); $loc->get('ViewHelperManager')->get('translate')->setTranslator($translator); View.phtml echo $this->translate('homepage'); The awnser: module.config.php 'translator' => array( 'locale' => 'it_IT', 'translation_files' => array( array( 'type' =>...

PHP ZF2 Mysql has gone away


php,mysql,zend-framework,zend-framework2
Hi I have a php daemon that handle request from rabbitmq After a day, it can no longer execute due to error MySQL has gone away. PHP Warning: PDOStatement::execute(): MySQL server has gone away in /var/www/daemon/www/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Statement.php on line 239 PHP Warning: PDOStatement::execute(): Error reading result set\'s header in /var/www/daemon/www/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Statement.php on...

zf2 call a method from a Model in another Model


model-view-controller,zend-framework2
I have a couple of modules in ZF2 project. Each module has different model classes performing different required functions. Now I have method in a model class of first module which I want to call in the model class of second module. Is it possible to do so? if yes,...

Zend 2 After login how to set user


zend-framework2,zend-db
I have the following code and which works, but now the next step. How and where do i have to set a session so the script "sees" that the user is already logged in? if ($form->isValid()) { $securePass = $this->getUsersTable()->getUserByUsername( $this->params()->fromPost('username') ); if( $securePass ){ $bcrypt = new Bcrypt(); if...

Zend Framework 2 Cache filesystem


php,zend-framework,zend-framework2
I've been using the filesystem adapter for cacheing data. E.g.. $cache = StorageFactory::factory(array( 'adapter' => array( 'name' => 'filesystem' 'options' => array('ttl' => 1800, 'cache_dir' => './data/cache'), ), )); But when using the getItem() function AFTER the TTL clocks over it returns false on success etc, which it should... However,...

zend framework 2 nested module structrue in one main module


php,zend-framework,zend-framework2
I am trying to create a app using zend framework 2. Have used structure as follow. Getting error class not found. Trying to created nested sub module login inside a main module called album. I have following structure: Album - src - Album - Controller - AlbumController.php - Form -...

How to make Zf2 Apigilty accept client request with no Accept set in header


php,zend-framework2,apigility,content-negotiation
Recently I have upgraded my rest server to Zf2 Apigility, which the content negotiation settings are as follows, 'zf-content-negotiation' => array( 'controllers' => array( 'CloudSchoolBusFileApi\\V1\\Rest\\FileReceiver\\Controller' => 'Json', ), 'accept_whitelist' => array( 'CloudSchoolBusFileApi\\V1\\Rest\\FileReceiver\\Controller' => array( 0 => 'application/vnd.cloud-school-bus-file-api.v1+json', 1 => 'application/json', ), ), 'content_type_whitelist' => array(...

How can I make PHPUnit ignore a file pattern?


php,zend-framework2,phpunit
I'm doing Code Coverage reports for a project and there's a ton of files that are included or required while tests are running that are not actually required to be tested or added to coverage reports (I'm using Zend Framework 2; config + Module files are the culprit here). Is...

Zend 2 Navigation add before label name


php,zend-framework2
I have the following navigation array, but now i want a before my label. How and where can i add this? The output must be: <ul class="sidebar-nav"> <li class="active"> <a href="/admin/users"><i class="gi gi-user sidebar-nav-icon"></i> Users</a> </li> </ul> Array module config: 'navigation' => array( 'default' => array( array( 'label' => 'Users',...

integrate login to my sites with OpenId or OAuth


login,zend-framework2,oauth-2.0,openid,integrated
i have a few site developed with zend framework 1 and zend framework 2,i wanna users register in main site and in other sites i want to have a login button ,if user click on login: 1- if user logged in in main site ago , user login without enter...

Zend Framework 2: Create Search Widget for Layout


php,zend-framework2
I have a small private Project to learn ZF2. I have integrated Zend Lucene as a Search Function. This works well, but I now want to integrate a Search Field in my Layout, so that it is available on all pages. I am really not sure how to achieve this....

Expecting Zend to fail to find an action, but instead it finds it and tries to render a view


php,routes,zend-framework2
With an action such as public function checkImagesAction() I can request that route in my browser with /checkImages and the page is displayed using the check-images.phtml view as I'd expect. However, requesting /checkImageS or another crazy spelling causes Zend to throw a RuntimeException because it is unable to render template...

how retrieve array returned by config in zend framework 2


zend-framework2
How I can get the array returned by config/autoload in zend framework 2? #config/autoload/myconfig.local.php return array('foo' => 'bar'); I noticed if the file have not "return array()" an exception will throw...

zf2 + doctrine2 and No Metadata Classes to process


php,doctrine2,zend-framework2,metadata
I'm using tutorial http://www.nuvolia.com/2013/03/09/zend_framework_doctrine_install/. The module Application fork fine with Doctrine ORM but when i'm tring to connect in another module i'm reciving error: d:\Aptana Studio\Projects\app01>vendor\bin\doctrine-module orm:schema-tool:create Deprecated: "Symfony\Component\Console\Helper\DialogHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\Qu estionHelper" instead. in D:\Aptana Studio\Projects\app01\vendor\symfony\console...

ZF2 / Doctrine / Cannot remove all elements from an ArrayCollection


php,doctrine2,zend-framework2
I have 2 entities, Product and Category with a bidirectional ManyToMany association mapping defined below : Product /** * @ORM\ManyToMany(targetEntity="Category", inversedBy="products") * @ORM\JoinTable(name="products_categories") */ protected $categories; // with these accessors public function addCategories(Collection $categories) { foreach ($categories as $category) { $this->addCategory($category); } return $this; } public function addCategory(Category $category) {...

Composer + Rocketeer + ZF2- Cannot install Rocketeer due to requirements conflict


php,zend-framework2,composer-php,rocketeer
Can somebody can tell me how to fix this? Rocketeer installs just fine in empty dir, but not along with my existing project, don't know w why. What is requiering that installation? - Installation request for symfony/console == 2.6.6.0 -> satisfiable by symfony/console[v2.6.6]. composer.json { "name": "zendframework/skeleton-application", "description": "Skeleton Application...

zend2 adding another controller to application


controller,routing,zend-framework2
I'm working on a ZendFramework2.4-project. I just got started an filled the IndexController of a standard skeleton application with some code and thought of another controller in the same application. No new modul, just a second Controller to keep code seperated. Of course I read the documentation at Zend2: Routing...

BETWEEN with range including '1' also returns '10'


php,mysql,zend-framework2,between
I'm getting some unexpected behaviour using a BETWEEN predicate in ZF2. Consider the following code: $ranges = array( array( 'min' => 2, 'max' => 4 ), array( 'min' => 7, 'max' => 9 ) ); $predicates = array(); foreach($ranges as $range){ // create a new 'Between' predicate and add it...

How to read a curl post with PHP


php,curl,zend-framework2
I'm using curl to post JSON to PHP and i'm struggling to read the data in PHP. This is how i'm using curl , curl -H "Content-Type: application/json" -X POST -d '{"email":"[email protected]","password":"xyz"}' http://example.com/api/login This is what iv'e tried in PHP 1) Using ZF2 functions: $email = (string) $this->params()->fromPost('email', null); 2)...

Best practice for Zend 2 FieldSets, re-use them or re-create them for every specific situation?


php,forms,doctrine2,zend-framework2
Me and my colleague were arguing about whether or not we should re-use certain Zend2 FieldSet classes in our project. Using the framework we create many different forms, and there are quite a few forms for which the same information needs to be filled in. For example, we have a...

D2l first time signature is matched but next time, it displays authenticated signature?


php,api,zend-framework2,php-5.3,desire2learn
I am trying to integrate the Desire2Learn (D2L) sandbox with my app. I created an API for a D2L request. The first time, the signature is matched, but after logging out of D2L and trying once again, it then displays an authenticated signature. But when I quit and restart my...

Zend Framwork 2 - Tablegateway - Updating only one column of a row in DB


php,mysql,database,zend-framework2,tablegateway
I have a table called users. It has the following columns: id name username email User can not edit any data from this table except the username column. The question is that when user wants to edit his username, what would the query be in ZF2 Tablegateway? In my controller...

Zend2 - ZF2 - Routing Issue


php,zend-framework2
i am trying to make my router working so that: /Auth redirects to Auth controller of Auth MOdule /Auth/Login redirects to Login controller of Auth Module While the first works just right the /Auth/Login results in routing issue. My router configuration file looks like below: 'router' => array( 'routes' =>...

ZF2 & Apigility - Correct way to setup GET and POST RPC services


zend-framework2,apigility
What is the correct way to setup GET and POST services in ApiGility? Currently, if I am setting up a GET service, I will include the variable I require in my route: /api/verify/merchant[/:merchant_code] And if I wish to setup a POST service, my route becomes: /api/verify/merchant And I add a...

Error in Array comparison in php


php,arrays,zend-framework,foreach,zend-framework2
Below are the sample arrays I'm Comparing. Table 1 $csvData= ( [0] =&gt; Array ( [Account Number] =&gt; 1.01100156278101E+15 [Posting Date] =&gt; 2014/07/08 [Value Date] =&gt; 2014/07/08 [Description] =&gt; Cash Withdrawal by Cheque-173320--TT1421957901 [Debit Amount] =&gt; 2000 [Credit Amount] =&gt; [Running Balance] =&gt; 388392.62 ) [1] =&gt; Array ( [Account...

ZF2 Bulk insert using INSERT INTO … SELECT from a table to same table


php,zend-framework2,bulkinsert,insert-into
I am trying to do a bulk copy of some records from a table into the same table with one field changed. But I am not able to find the correct method in ZF2 for it. My existing table looks like this : CoID -- CatCode -- CategoryName PP --...

Zend Framework 2 - Accessing 2 different tables from same controller file


php,mysql,module,zend-framework2,tablegateway
I have succesfully completed the the album table tutorial in Zend Framework 2 manual. I have implemented using tablegateway. I can see that he used only one table named "album" and hence he implemented according to that one table. Lets say I have another table called "artist" that holds the...

Create a subquery using ALL and ANY statements


mysql,zend-framework2,any
I'm trying to make this query SELECT * FROM district WHERE id = ANY (SELECT districtId FROM address WHERE id = ANY (SELECT addressId FROM schedule WHERE workshopId = '1')) My real problem is inserting the ANY statement. Does anyone know how to apply ANY or ALL to the query...

Validator EmailAddress can validate an array of email


php,validation,email,zend-framework2,jquery-select2
I have a select2 field (tags) wich need to be validated with EmailAddress validator from Zend framework 2. the post from select2 field is like this : '[email protected], [email protected]' From here, my form has an input filter wich looks like this : public function getInputFilterSpecification() { return array( 'name' =>...

Zend Framework 2 - Showing the content of a database


php,mysql,database,pdo,zend-framework2
I'm making some kind of market site with Zend Framework 2. The home got a slider showing all the products (realized with CSS3 keyframes) and some text. Both the sliding pictures and the text are read from a MySQL database. But as result, i get no output but also no...

CORS POST request in ZF2 becomes OPTIONS request instead


php,zend-framework2,cors
Is there anyway in Zend Framework 2 to allow CORS on my API? I have already allowed all origins header("Access-Control-Allow-Origin: *"); Every time I send a POST request with headers the server responds with 405. On my access log I see the the request is actually OPTIONS...

ZF2 DB Adapter - Column not found: 1054 Unknown column


mysql,zend-framework2
I'm using ZF2 DB Adapter and get following error on my query: Column not found: 1054 Unknown column '"product"' But "product" is no column, it's a value, so how come? This is how I build the query: $select = $this->getGateway()->getSql()->select(); $select->join('keywordlink', 'keywordlink_ref_type = "product" AND keywordlink_ref_id = product_id', ['keyword_count' =>...

PHP/Zend Framework 2 - Unable to display table field values within dynamically generated table


php,mysql,model-view-controller,zend-framework2
Problem I am trying to display field values into a table using Zend Framework 2 and PHP/MySQL. Given the following table which is dynamically generated, I am trying to get the values shown below. Unfortunately, I only get empty values for the cell locations. Question How can I solve this...

PHP Frameworks and Project Repositories


php,git,github,zend-framework2,repository
I'm starting a new in PHP and for the first time I'm going to use a framework as the basis of the project. I've decided to use Zend Framework 2 for it. I'm going to be version controlling the project via Github. Is it normal to include all the framework...

The class 'Doctrine\ORM\EntityManager' was not found in the chain configured namespaces XXX


php,doctrine2,zend-framework2,doctrine
I have read the the other questions concerning this issue but have not come across a solution as of yet. I get the following error message: The class 'Doctrine\ORM\EntityManager' was not found in the chain configured >namespaces ZfcUser\Entity, Common\Entity, Employment\Entity, Intern\Entity, >Team\Entity, PurchaseRequest\Entity. I have a HolidayEntity, HolidayController, HolidayService. Adding...

Pass array on url using zend framework 2 routes


php,zend-framework,routes,zend-framework2
I have a web app that lets user make multiple searches and show the results of that searches all on the same page. Here's a basic structure: Search 1 - Attribute 1 = X - Attribute 3 = Y Search 2 -Attribute 2 = Z All these results are loaded...