Graham Kennedy
Graham Kennedy

Reputation: 736

Fatal Error While Running Artisan (Laravel) on Command Line

I am experiencing a fatal error while using artisan on the (fantastic) Laravel PHP framework.

I recently downloaded v3.2.1 of Laravel, and I tried running the following command line from within the directory that artisan resides:

php artisan key:generate

This should create a random key for me in my applications/application.php file. (Please see http://laravel.com/docs/artisan/commands for a specific reference to this command.)

However, when I run this command from the shell I receive 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's on line 62 of paths.php:

chdir(__DIR__);

This is what's on line 1 of core.php:

<?php namespace Laravel;

My question is this: Are there any specific environment, directory, or other permissions that I should modify to get artisan up and running.

A little background:

My environment:

My root directory: (permissions in parenthesis)

Please let me know if there are any other details about my setup that relevant. I'm really not sure what will help in troubleshooting this issue.

--

UPDATE: I also posted this issue to Laravel's GitHub issue tracker. (https://github.com/laravel/laravel/issues/820)

Upvotes: 6

Views: 5819

Answers (2)

Graham Kennedy
Graham Kennedy

Reputation: 736

First off, thanks @KingCrunch, your first response led me down the correct path toward resolving this issue. Additionally, I received an excellent response from Dreamhost technical support (specifically Gary S), who gave me the concise answer I was looking for.

The issue was: I was running PHP 5.2.17 at the CLI, whereas my web server was running PHP 5.3.13.

The resolution is: Use

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

when running artisan commands at the CLI. This will ensure that all of my artisan commands are run using PHP 5.3 and above, which satisfies Laravel's PHP 5.3+ requirements.

Upvotes: 10

KingCrunch
KingCrunch

Reputation: 131841

Namespaces and the __DIR__-pseud-constant were introduced in PHP 5.3. It seems you are running an old version. You should update to at least 5.3.

php -v

Upvotes: 5

Related Questions