Fatal error when starting Artisan (Laravel) on the command line

I am experiencing a fatal error when using wizards in the (fantastic) Laravel PHP framework.

I recently downloaded v3.2.1 from Laravel, and I tried to run the following command line from the directory where artisan is located:

php artisan key:generate 

This should create a random key for me in my application / application.php application. (See http://laravel.com/docs/artisan/commands for a specific link to this command.)

However, when I run this command from the shell, I get the following error:

 Warning: chdir(): No such file or directory (errno 2) in /home/[USERNAME REMOVED]/websites/[DIRECTORY REMOVED]/htdocs/dev/sb4/paths.php on line 62 Parse error: syntax error, unexpected T_STRING in /home/[USERNAME REMOVED]/websites/[DIRECTORY REMOVED]/htdocs/dev/sb4/laravel/core.php on line 1 

This is what is on line 62 of the .php path:

 chdir(__DIR__); 

This is what is in line 1 of the core.php file:

 <?php namespace Laravel; 

My question is this: is there any specific environment, directory or other permissions that I have to change in order to start and run artisan.

A bit of background:

  • I first installed Laravel 3.2.1 for the first time
  • I can successfully run a simple web application on my system (i.e. I can send a request to the controller and load the corresponding blade server correctly).
  • I just downloaded Laravel 3.2.1 (laravel-laravel-v3.2.1-8-gaae8b62.zip) from GitHub and extracted it to my server.

My environment:

  • PHP 5.3.13 on a shared host in Dreamhost
  • Firessh to run commands

My root directory: (permissions in brackets)

  • / application (775)
  • / bundles (775)
  • / laravel (775)
  • / public (775)
  • / storage (775)
  • / artisan (664)
  • /paths.php(777)

Please let me know if there are any other details about my setup that are relevant. I am really not sure what will help in fixing this problem.

-

UPDATE: I also posted this issue for Laravel GitHub. (Https://github.com/laravel/laravel/issues/820)

+4
source share
2 answers

First of all, thanks @KingCrunch, your first answer led me to the correct way to solve this problem. In addition, I received an excellent response from Dreamhost technical support (specifically Gary S) that gave me the short answer I was looking for.

The problem was that I was running PHP 5.2.17 in the CLI, while PHP 5.3.13 was running on my web server.

Resolution: Use

 /usr/local/php53/bin/php artisan <command> 

when running wizard commands in the CLI. This ensures that all my wizard commands run using PHP 5.3 and higher, which meets the requirements of Laravel PHP 5.3+.

+9
source

Namespaces and the __DIR__ -pseud constant were introduced in PHP 5.3. You seem to be using the old version. You must upgrade to at least 5.3.

 php -v 
+4
source

All Articles