Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class not found error only on production server

I'm working on a project using Silex. In a particular file, I've added a use statement to have the autoloader include a particular php file. Later in the file, I use that class. All is well on the development server, but when I move to production, I get a Fatal error: Class not found message. Edit: Both servers now use PHP 5.4.4.

Are there any kind of installation specific issues that might be causing this? I can confirm that both namespace autoload files generated by composer are the same.

Just for the sake of thoroughness, here is the include statement:

use Instaphp;

Here is the use of the class later in the code:

$app['instaphp'] = $app->share(function() use ($app) {
            if($app['tagframe.instagram_token'] === null) {
                return Instaphp\Instaphp::Instance();
            } else {
                return Instaphp\Instaphp::Instance($app['tagframe.instagram_token']);
            }
        });

        $app['instaphp.config'] = $app->share(function() use ($app) {
            return Instaphp\Config::Instance();
        });

Here is the exact error:

Fatal error: Class 'Instaphp\Config' not found in /var/www/silexsandbox/src/TagFrame/Silex/TagFrameServiceProvider.php on line 89

Update: I should add that I have experienced no such errors anywhere else in the fairly large code base I'm working on, so I know it's not as simple as ALL namespaces not working.

like image 904
itsmequinn Avatar asked Sep 19 '12 23:09

itsmequinn


2 Answers

By default, Mac's use a Journaled Case-Insensitive Filesystem. Linux, depending on your flavor, mostly is case-sensitive. This will definitely result in the behavior you described above.

I would suggest you create a second partition on your Mac and format it as Journaled Case-Sensitive to it matches closer to your production environment.

like image 181
Mike Mackintosh Avatar answered Nov 11 '22 10:11

Mike Mackintosh


Thanks for the comments. I did make sure that I updated using Composer so that the autoloader was dumped.

The problem (as I found out after hours of fiddling) was that the directory structure for the third-party library I was using (Instaphp) was lower-case. This didn't give my Mac a problem, but the production server is running Ubuntu, which I suppose uses case-sensitive file handling utilities where the Mac does not.

I'm totally kicking myself for spending a night on this!

like image 32
itsmequinn Avatar answered Nov 11 '22 11:11

itsmequinn