Nick F
Nick F

Reputation: 10112

FuelPHP's Autoloader is failing to find classes

I'm having a problem with FuelPHP failing to autoload classes. On my staging server (Ubuntu, PHP 5.3.10) it is unable to find custom classes in the fuel/app/classes directory, and it also can't run oil test (I get the error message sh: 1: phpunit: not found). Oddly, it works fine on my local development version (Windows, PHP 5.3.6).

I suspected it might have something to do with Composer, which I'm using for the first time on this project, but the problem is not fixed when I comment out the line require APPPATH.'vendor/autoload.php'; from bootstrap.php (the app still fails to load custom classes from fuel/app/classes)

I'm stumped: I've used FuelPHP on lots of projects and have never had any problems with the Autoloader. What's particularly puzzling is that the same code seems to work fine in one place and not in another. I'd be very grateful for any suggestions about how to fix this.

Upvotes: 0

Views: 1685

Answers (1)

turtlechief
turtlechief

Reputation: 100

I realize this question was asked a long time ago, but I had the same problem, so for the benefit of anyone else with this problem, here is what worked for me:

create a new php file called oil.php in the app/config directory with the following code:

<?php

// Unit tests will get shell error 'phpunit: command not found' unless
//  the path to php unit is specified.
 return array (
     'phpunit' => array (
         'binary_path' => 'fuel/vendor/bin/phpunit',
     ),
 );

I am using fuel 1.7.2. More information can be found here.

Although the above code fixed the specific PHPunit problems, I still had issues with Fuel and autoloaders not working. Fuel PHP does not follow psr-4 (many of the core fuel files have multiple class definitions in the same file), which can cause problems with certain autoloaders.

Upvotes: 1

Related Questions