Issues

ZF-7465: zf create controller fails on Windows with ZF 1.9

Issue Type: Bug Created: 2009-08-04T02:18:53.000+0000 Last Updated: 2012-05-13T21:27:43.000+0000 Status: Resolved Fix version(s): - 1.9.1 (11/Aug/09)

Reporter: Rob Allen (rob) Assignee: Ralph Schindler (ralph) Tags: - Zend_Tool

Related issues: Attachments:

Description

On Windows, using trunk or release-1.9 branch:

zf create project mytest cd mytest zf create controller foo

Generates this error:

<pre class="highlight">
                       An Error Has Occurred
 A project profile was not found.

Zend Framework Command Line Console Tool v1.9.0a1
Details for action "Create" and provider "Controller"
  Controller
    zf create controller name index-action-included[=1] module

Comments

Posted by Rob Allen (rob) on 2009-08-04T02:38:17.000+0000

The problem is on line 126 of Zend/Tool/Project/Provider/Abstract.php:

$projectDirectoryAssembled = DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $parentDirectoriesArray);

On Windows, this creates a $projectDirectoryAssembled of \C:\www\mytest for me!

Clearly the leading \ is wrong for Windows. Suggested patch:

<pre class="highlight">
Index: Zend/Tool/Project/Provider/Abstract.php
===================================================================
--- Zend/Tool/Project/Provider/Abstract.php (revision 17369)
+++ Zend/Tool/Project/Provider/Abstract.php (working copy)
@@ -123,7 +123,11 @@
         
         $parentDirectoriesArray = explode(DIRECTORY_SEPARATOR, ltrim($projectDirectory, DIRECTORY_SEPARATOR));
         while ($parentDirectoriesArray) {
-            $projectDirectoryAssembled = DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $parentDirectoriesArray);
+            $projectDirectoryAssembled = implode(DIRECTORY_SEPARATOR, $parentDirectoriesArray);
+            if(substr(PHP_OS, 0, 3) != 'WIN') {
+                // prepend the DIRECTORY_SEPARATOR only if not on Windows
+                $projectDirectoryAssembled = DIRECTORY_SEPARATOR . $projectDirectoryAssembled;
+            }
             
             $profile->setAttribute('projectDirectory', $projectDirectoryAssembled);
             if ($profile->isLoadableFromFile()) {

Posted by Rob Allen (rob) on 2009-08-10T01:13:28.000+0000

Alternative patch from ZF-7338:

<pre class="highlight">
Index: Abstract.php
===================================================================
--- Abstract.php    (revision 16969)
+++ Abstract.php    (working copy)
@@ -120,11 +120,14 @@
         }
 
         $profile = new Zend_Tool_Project_Profile();
-        
-        $parentDirectoriesArray = split(DIRECTORY_SEPARATOR, ltrim($projectDirectory, DIRECTORY_SEPARATOR));
+        $parentDirectoriesArray = split(preg_quote(DIRECTORY_SEPARATOR), ltrim($projectDirectory, DIRECTORY_SEPARATOR));
         while ($parentDirectoriesArray) {
-            $projectDirectoryAssembled = DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $parentDirectoriesArray);
+            $projectDirectoryAssembled = implode(DIRECTORY_SEPARATOR, $parentDirectoriesArray);
             
+            if (DIRECTORY_SEPARATOR != "\\") { // Seems to be a windows path
+              $projectDirectoryAssembled = DIRECTORY_SEPARATOR . $projectDirectoryAssembled;
+            }
+            
             $profile->setAttribute('projectDirectory', $projectDirectoryAssembled);
             if ($profile->isLoadableFromFile()) {
                 chdir($projectDirectoryAssembled);

Posted by Ralph Schindler (ralph) on 2009-08-10T08:38:40.000+0000

Fixed in r17521 in trunk

Posted by fran├žois BOUKHALFA (_ceone) on 2009-08-12T08:52:24.000+0000

Hi sorry but i've just do a fresh checkout (r17563) and tried zf.bat on windows XP and it didn't worked for me :

i had to edit Abstract.php on line 126 like this to make it work

        $projectDirectoryAssembled = implode(DIRECTORY_SEPARATOR, $parentDirectoriesArray);

regards

Posted by Ralph Schindler (ralph) on 2009-08-12T10:38:43.000+0000

Updating Fix Information

Posted by Rob Kunkle (goodlux) on 2009-08-14T00:10:31.000+0000

I just checked out 1.9.1 from subversion, and this bug is still there. The second fix above works for me, but I do get the following (php 5.3.0) due to the use of the split()

Deprecated: Function split() is deprecated in C:\Program Files\Zend\ZendServer\share\ZendFramework\library\Zend\Tool\Project\Provider\Abstract.php on line 124

thanks!

Posted by Sebastian Schurr (stoggy) on 2009-08-16T20:03:52.000+0000

Same here. Just checked the 1.9.1 SVN. In abstract.php (Revision 17521) it should be fixed but still doesn't work for me.

This worked for me:

<pre class="highlight">
if (DIRECTORY_SEPARATOR == "\\") {
    $projectDirectoryAssembled = implode(DIRECTORY_SEPARATOR, $parentDirectoriesArray);
    } else {
    $projectDirectoryAssembled = DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $parentDirectoriesArray);
}

inserted at line 127.

thanks!

Posted by Murad Jamal (unpresedented) on 2009-08-18T01:05:38.000+0000

guys i can't find the line: $projectDirectoryAssembled .... etc ... in C:\Program Files\Zend\ZendServer\share\ZendFramework\library\Zend\Tool\Project\Provider\Abstract.php and also i can't find the line : $parentDirectoriesArray ... etc .. in the same file ...

where can i find these lines to fix them ? im stuck now ...

Posted by Murad Jamal (unpresedented) on 2009-08-18T02:49:30.000+0000

i downloaded latest version of zend framework, and i find those lines in abstract.php i tried both solutions but didn't work ... i still see the same message :( a project profile was not found ... why ???

anyone help me please ...

Posted by Enkhbilguun Erdenetsogt (beregu) on 2009-08-18T03:48:38.000+0000

I'm working on ZF1.9.1 and Zend Studio 7.0. Both ZF 1.9.1 and ZS 7.0's Zend_Tool is not working properly. I cannot create neither controller nor action. Therefore ZS 7.0's code autocompletion has become maybe 5 times slower and has too many bugs like alpha or beta build.

Posted by Murad Jamal (unpresedented) on 2009-08-18T04:54:16.000+0000

here's the error message i get:

C:\Users\Administrator\Zend\workspaces\DefaultWorkspace7>"C:/Program Files/Zend/Zend Studio - 7.0.0/plugins/org.zend.php.framework.resource_7.0.0.v20090531-1639/resources/ZendFramework-1/bin//zf.bat" create action edit index An Error Has Occurred
A project profile was not found.

Zend Framework Command Line Console Tool v1.9.1
Details for action "Create" and provider "Action"
  Action
    zf create action name controller-name[=index] view-included[=1] module

what the hell is this ? i tried all the solutions you wrote, but without any effect ...

Posted by Rob Kunkle (goodlux) on 2009-08-18T09:34:49.000+0000

Hi Murad -

The problem is that you need to be in the project directory when you run zf create action...otherwise zf can't find the project profile

cd c:\apache\htdocs\

zf create project myproject

cd C:\apache\htdocs\myproject\

then

zf create controller blah blah


Is there any way to reopen this bug to get the source code fixed?

Posted by Murad Jamal (unpresedented) on 2009-08-18T23:35:51.000+0000

Hi Rob, i tried exactly what you told me without any benefit :( from inside my zend studio 7, i opened Zend Tool, typed cd C:\Program Files\Zend\Apache2\htdocs\project1 but it gives me the following error:

cd C:\Program Files\Zend\Apache2\htdocs\project1 Error resolving path: cd C:\Program Files\Zend\Apache2\htdocs\project1, specify an existing ZF project. Error resolving path: cd C:\Program Files\Zend\Apache2\htdocs\project1, specify an existing ZF project. ok (took 0:00.000) Error: Error resolving path: cd C:\Program Files\Zend\Apache2\htdocs\project1, specify an existing ZF project.

although there was an existing zend framework project in that directory ... this is so weird ? anyone can help me please ?

Posted by Carsten Schmitz (trady) on 2009-08-19T14:14:27.000+0000

I have with ZF 1.9.1 the same problem like in the description at the top.

The following code doesn't work: zf create project test => OK - cd test - zf create controller guestbook => Error!

With ZF 1.8.4 Patch 1 the code works.

Posted by Ralph Schindler (ralph) on 2009-08-24T12:07:21.000+0000

Please see ZF-7607, a fix as been put in place in trunk and release 1.9 branch that fixes this issue.

Posted by sarfaraz ahmed (sarfaraz99) on 2012-05-13T21:27:43.000+0000

You are getting this error

An Error Has Occurred A project profile was not found.

Zend Framework Command Line Console Tool v1.9.0a1 Details for action "Create" and provider "Controller" Controller zf create controller name index-action-included[=1] module

Solution : You are trying to run the ZF in wrong place.

Go to your project > application directory > Controller and then type

zf create controller foo

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts