Reputation: 6623
this one has me stumped. I'v git clone
ed my repo on Digital Ocean (LEMP stack) and checked out the development
branch. All good at this point. Then I do a composer install
to install the deps, this dies with:
PHP Fatal error: Class 'App\MyApp\Api\Transformers\ProjectTransformer' not found
in /home/greg/MyApp/app/Providers/DatabaseServiceProvider.php on line 67
The DatabaseServiceProvider
has a use
statement at the top like:
use App\MyApp\Api\Transformers\ProjectTransformer;
This is a laravel 5 project for what it's worth. The DatabaseServiceProvider.php
has the namespace namespace App\Providers;
The contents of the ProjectTransformer
that composer is complaining about is:
<?php namespace App\MyApp\Api\Transformers;
class ProjectTransformer extends Transformer
{
/**
* @var array
*/
protected $visible_fields = [
'id',
'title',
'client_id',
'division_id',
'project_manager_id',
'probability',
'total_contract_value',
'description',
'devs'
];
}```
So, composer
is stating that I'm using ProjectTransformer
in DatabaseServiceProvider
and that can't be found. The file absolutely exists, the namespaces appear to be correct...what else am I missing? The other odd issue is that I can composer install
this branch from scratch locally (on homestead) with no issue. Only on digital ocean is it complaining. Thanks for any advice!
Upvotes: 0
Views: 506
Reputation: 15770
In the shell, try this:
composer install --no-scripts
If that runs successfully, then try it again without the --no-scripts
tag.
The --no-scripts
tag will prevent composer from running any of the Laravel-specific set up/tear down scripts that are usually run as part of the composer operations. The error message you're seeing is likely due to the fact that your Laravel installation is not completely set up yet (which is not surprising, since you're trying to install it in a new place).
It's kind of a chicken-and-egg problem: the autoloader is not set up yet so it can't resolve the namespaces. But it can't set up the autoloader because it fails because Laravel is complaining that it can't resolve the appropriate namespaces.
Running composer without the scripts will give composer a chance to do its work - install the appropriate packages, initialize the autoloader - without failing because Laravel can't find the packages it needs. Then, once composer has had a chance to do it's thing, you can run it again and Laravel will find what it needs.
Upvotes: 1