Fatal Error While Running Artisan (Laravel) on Command Line
Asked Answered
G

2

6

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)

Goldman answered 13/6, 2012 at 5:19 Comment(0)
G
10

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.

Goldman answered 16/6, 2012 at 11:29 Comment(0)
H
5

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
Hocker answered 15/6, 2012 at 8:38 Comment(2)
Hi @KingCrunch, Thank you for the reply, and I think you're corrent. I'm experiencing a weird situation. My web service is running PHP 5.3.13. I can verify this by calling phpinfo(). However, when I run php -v at the command line, it's showing that I'm running PHP 5.2.17. I'm looking into why this may be the case. I'll post my findings here when I get some feedback or a definitive answer.Goldman
Seems, that you have multiple php installations ;) You can use which php and/or whereis php to find the used cli installation.Hocker

© 2022 - 2024 — McMap. All rights reserved.