Issue Details (XML | Word | Printable)

Key: ZF-7465
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Ralph Schindler
Reporter: Rob Allen
Votes: 1
Watchers: 5
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

zf create controller fails on Windows with ZF 1.9

Created: 04/Aug/09 02:18 AM   Updated: 24/Aug/09 12:07 PM   Resolved: 10/Aug/09 08:38 AM
Component/s: Zend_Tool
Affects Version/s: 1.9.0
Fix Version/s: 1.9.1

Time Tracking:
Not Specified


 Description  « Hide

On Windows, using trunk or release-1.9 branch:

>zf create project mytest
>cd mytest
>zf create controller foo

Generates 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


Rob Allen added a comment - 04/Aug/09 02:38 AM

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:

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()) {

Rob Allen added a comment - 10/Aug/09 01:13 AM

Alternative patch from ZF-7338:

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);

Ralph Schindler added a comment - 10/Aug/09 08:38 AM

Fixed in r17521 in trunk


françois BOUKHALFA added a comment - 12/Aug/09 08:52 AM

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


Ralph Schindler added a comment - 12/Aug/09 10:38 AM

Updating Fix Information


Rob Kunkle added a comment - 14/Aug/09 12:10 AM

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!


Sebastian Schurr added a comment - 16/Aug/09 08:03 PM

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:

if (DIRECTORY_SEPARATOR == "\\") {
    $projectDirectoryAssembled = implode(DIRECTORY_SEPARATOR, $parentDirectoriesArray);
    } else {
    $projectDirectoryAssembled = DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $parentDirectoriesArray);
}

inserted at line 127.

thanks!


Murad Jamal added a comment - 18/Aug/09 01:05 AM

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 ...


Murad Jamal added a comment - 18/Aug/09 02:49 AM

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 ...


Enkhbilguun Erdenetsogt added a comment - 18/Aug/09 03:48 AM

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.


Murad Jamal added a comment - 18/Aug/09 04:54 AM

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 ...


Rob Kunkle added a comment - 18/Aug/09 09:34 AM

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?


Murad Jamal added a comment - 18/Aug/09 11:35 PM

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 ?


Carsten Schmitz added a comment - 19/Aug/09 02:14 PM

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.


Ralph Schindler added a comment - 24/Aug/09 12:07 PM

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