rsanchez/craft-cli

Class 'Craft\PhpMessageSource' not found; line 213

ncksnydr opened this issue · 12 comments

  1. Installed via brew.
  2. php.ini sockets are set correctly (via MAMP)
  3. Craft is updated to the latest build: Craft Pro 2.5.2761
  4. By running any command in the Terminal, I am getting:
    Fatal error: Class 'Craft\PhpMessageSource' not found in /Users/Nick/Sites/Website/_dev/_build/craft/app/framework/YiiBase.php on line 213

Any idea what this could be?

To double check you have the right mysql socket settings you can run this command:

php -i | grep pdo_mysql.default_socket

For my MAMP setup, this prints:

pdo_mysql.default_socket => /Applications/MAMP/tmp/mysql/mysql.sock => /Applications/MAMP/tmp/mysql/mysql.sock

Does the site work fine via web browser?

The only thread I found that had a similar error: http://craftcms.stackexchange.com/questions/9656/craft-hosted-on-google-app-engine-failing-to-load-craft-classes Maybe it's a file permissions thing?

I'd try debugging with debug in the craft/app/framework/YiiBase.php createComponent method line 213.

Thanks for such a speedy reply! Below are the debugging steps that I have taken.

  1. I checked the mysql socket settings, per your instructions, and got a different path than my php.ini file:
    a
  2. However: when I echo a phpinfo() in the same directory as my Craft public directory, the socket says it is correct:
    a
  3. Same goes for dumping line 213 of craft/app/framework/YiiBase.php:
    a
  4. I even went ahead and forced a socket in the config/db.php array for all environments:
    a
  5. I even went ahead and did chmod -R 777 craft/app/ to ensure there were no permission issues:
    a

My best guess is that the issue has to do with getting the different path from typing php -i | grep pdo_mysql.default_socket into the Terminal. Is there a way to set the socket, system-wide? My Google Fu is failing me this morning.

Update:

  1. I added this line to my .bash_profile:
    export PATH="/Applications/MAMP/bin/php/php5.5.26/bin:$PATH"

...then reloaded the profile and also restarted my system. Now when I type php -i | grep pdo_mysql.default_socket into the console, I get pdo_mysql.default_socket => /Applications/MAMP/tmp/mysql/mysql.sock => /Applications/MAMP/tmp/mysql/mysql.sock.

However, I am still getting the error—and now I'm even getting it twice:

PHP Fatal error:  Class 'Craft\PhpMessageSource' not found in /Users/Nick/Sites/Website/_dev/_build/craft/app/framework/YiiBase.php on line 213

Fatal error: Class 'Craft\PhpMessageSource' not found in /Users/Nick/Sites/Website/_dev/_build/craft/app/framework/YiiBase.php on line 213

I'll keep debugging; please let me know if you have suggestions.

Works:

  • craft help
  • craft init
  • craft install
  • craft list

Does Not Work (All 'Craft\PhpMessageSource' not found error):

  • craft console
  • craft clear:cache
  • craft db:backup
  • craft show:config

Untested:

  • craft generate:command
  • craft install:plugin

In a very similar boat.

Fatal error: Class 'Craft\PhpMessageSource' not found in /Users/Harry/Projects/Websites/untitled folder/craft/app/framework/YiiBase.php on line 213

Using any site-specific commands doesn't seem to play ball.

I'm starting to think this might not have to do with MySQL settings.

Can either/both of you tell me what you see when you type which php into your console?

@Harry-Harrison Are you using MAMP as well? Pro or not?

Can either/both of you supply a backtrace (debug_print_backtrace() or xdebug log)? This error occurs in the createComponent method of YiiBase. I'd love to see the $config array there, and where this class got called from.

@rsanchez Hey, yeah. Sorry, should've been clearer. /Applications/MAMP/bin/php/php5.6.10/bin/php I'll try and get a log over tomorrow.

@rsanchez

1: /Applications/MAMP/bin/php/php5.6.10/bin/php

2:

array(1) {
  ["class"]=>
  string(22) "Craft\PhpMessageSource"
}

Well... I figured it out...

In craft/app/framework/base/CModule.php:520 craft parses the config and will assign runtimePath property to the path in your system.

Unfortunately, when this folder craft/storage/runtime doesn't exist - likely not to exist if you use the console without setting the web app for example - it will throw Fatal error: Class 'Craft\PhpMessageSource

Let me know if that fixes the issue for you. Did the trick for me by creating the directory.

I'm going to try to this first thing tomorrow. If it works, I'm going to
need your PayPal account because I'm buying you a beer.

On Wednesday, August 24, 2016, Romain Palmas notifications@github.com
wrote:

Well... I figured it out...

In craft/app/framework/base/CModule.php:520 craft parses the config and
will assign runtimePath property to the path in your system.

Unfortunately, when this folder craft/storage/runtime doesn't exist -
likely not to exist if you use the console without setting the web app for
example - it will throw Fatal error: Class 'Craft\PhpMessageSource

Let me know if that fixes the issue for you. Did the trick for me by
creating the directory.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#4 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAzNlVP543-MG6ldWrlXpLZvCinCfF3Mks5qi_JngaJpZM4HRN05
.

Thanks,


Nick Snyder
WEB: http://nicksnyder.is
CELL: +1 856 630 3227

I've added some checks to the craft-cli bootstrap to the latest release, to see if the runtime folder exists and is writable. If not, it will attempt to create it. Hopefully this will sort this issue out.

Closing for now, please feel free to re-open if you are still having an issue here.