7

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.

itsmequinn
  • 1,054
  • 1
  • 8
  • 21
  • May sound trivial, but are you sure you have installed the vendors (or updated after the latest change) on the production server? – Maerlyn Sep 20 '12 at 10:16
  • Are you running PHP-FPM? Perhaps with APC enabled? Can you try reloading the FPM workers? – igorw Sep 20 '12 at 11:43

2 Answers2

8

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.

Mike Mackintosh
  • 13,917
  • 6
  • 60
  • 87
  • 1
    You can indeed format another partition in Case Sensitive mode on osx, but it doesn't seem to be recommended for your os partition as some applications will just fail to run. Ex: Photoshop https://helpx.adobe.com/creative-suite/kb/error-case-sensitive-drives-supported.html It's probably ok to have an other partition like this thought :) – GabLeRoux Mar 09 '15 at 07:34
6

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!

itsmequinn
  • 1,054
  • 1
  • 8
  • 21