Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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

My environment:

  • PHP 5.3.13 on a shared host at Dreamhost
  • FireSSH to run the commands

My root directory: (permissions in parenthesis)

  • /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 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)

like image 654
Graham Kennedy Avatar asked Jun 13 '12 05:06

Graham Kennedy


1 Answers

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.

like image 145
Graham Kennedy Avatar answered Oct 20 '22 01:10

Graham Kennedy