can't composer install / update on digital ocean, class not found - composer-php

this one has me stumped. I'v git cloneed 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!

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.

Related

Not found Class 'Jenssegers\Agent\Agent' not found in Laravel

I have tried many times to install laravel on ubuntu 18.04. but there is a error showed in terminal. Please help me how to solve this.
user#user:/opt/lampp/htdocs/project$ php artisan serve
In constants.php line 4:
Class 'Jenssegers\Agent\Agent' not found
Autoloading
You have to be sure, that your autoloading file is up to date.
Also, be sure that all packages from your composer.json are installed currently.
composer install will take care of both.
Wrong class name
If you have checked the above the issue could be, that the autoloader is looking for a class name, that doesn't exists due to discrepancy between the filename and classname. E.g. you called the file "UserAgent.php", but the class name inside the file is "Agent".
you can run composer install to fix the error. it works for me.

Why are there naming collisions in Composer's vendor folder? (between bin and hhvm)

I have been learning to use hacklang and hhvm and I have went about using composer and installing all the needed packages as
composer require hhvm/hsl hhvm/hhvm-autoload
composer require --dev hhvm/hhast hhvm/hacktest facebook/fbexpect
I have also setup the .hhconfig aswell as the hh_autoload.json and hhast-lint.json
However there is a naming collision between the Vendor/bin and Vendor/HHVM
Can anyone explain why this is happening or how to fix it?
This happens because composer copies vendor/vendor/package/bin/file to vendor/bin/file, causing symbols in vendor/vendor/package/bin/file to be defined twice. IT IS EXPECTED.
to avoid naming issues, add the following to your .hhconfig :
ignored_paths = [ "vendor/.+/tests/.+", "vendor/.+/bin/.+" ]

Class 'Stripe\Stripe' not found error in PHP

I installed laravel and composer and created my first project in laravel. I want to integrate stripe using PHP. When I try to execute my first project in localhost I take this message:
Fatal error: Class 'Stripe\Stripe' not found in C:\xampp\htdocs\laravel\stripe\public\elda.php on line 21
To include the stripe libraries, I inserted inside the composer.json file the code from the API library for PHP. Here is an image of my composer.json file:
I run composer install in cmd and this is the output:
You may be getting outdated dependencies. Run update to update them.
I run composer update and the output is the error in the image below:
Can someone help me to solve this error?
Well, sorry did not make a comment of your post, but I have not enough points to do so. But you need to run composer install in the terminal after that includes a new package.
I had the same issue, but when I ran this command my issue is resolved.
composer require stripe/stripe-php
I hope this may help you, after you update your composer.

How to install Laravel 4 profiler

I'm a Ubuntu/git/composer noob, and I'm trying to follow the installation instructions here.
After running the php artisan config:publish loic-sharma/profiler command I get the following error:
PHP Fatal error: Class 'Profiler\ProfilerServiceProvider' not found in /var/www/epcr/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 158
I'm assuming the problem is that I haven't downloaded the code, but I'm not exactly sure how to go about doing that.
Most packages require you to manually add service provider in app/config/app.php. There is an array of providers inside.
Some providers require also facade alias.
So take a look at documentation, if it is provider, then it should be documented.
e.g.
'Miro\JSONSuite\JSONSuiteServiceProvider'
Try running composer dump-autoload
I needed to run composer update after I added the require to my composer.json file. After that I had a few permissions I needed to update and it worked after that.

Laravel: Can't install Sentry

I tried to install Sentry 2 with composer. I used the composer manuel from the sentry site,
but i got always a serviceprovider exception:
"Class 'Cartalyst\Sentry\SentryServiceProvider' not found"
Is there an another way or i did something wrong?
If you look closely on the [Sentry website installer instructions for laravel 4],
step one states that you need to add "cartalyst/sentry": "2.0.*" to your composer.json,
but it also specifically states that it requires you to run php composer.phar update from the command line
Note that you should run php composer.phar update BEFORE you add the entries for the app/config/app.php (before proceeding to steps 2 and above)
#Todd Isaacs's answer would also lead you to the required result but you do not need to go back to the beggining, all you have to do is revert the changes on your app/config/app.php file and run the update.
hope that helps.
I found the solution. SSL is necessary for composer update and now all works fine.
So I checked the php ini and set ssl on.
I just got this same error and being totally new at Laravel I decided to step back, here is what I did to resolve it.
removed the entries I added to my composer.json and app.php (I think app.php was the issue)
run composer update (yep worked this time)
added "cartalyst/sentry": "2.0.*" to my composer.json
run composer update (sentry was installed)
added 'Cartalyst\Sentry\SentryServiceProvider' and 'Sentry' => 'Cartalyst\Sentry\Facades\Laravel\Sentry' to my app.php
run composer update (still works)
When I originally installed Sentry I added the 'Cartalyst\Sentry\SentryServiceProvider' to the app.php before running the update and I think this was the issue. ( install instructions )
For Sentry 3, change the service provider in app/config/app.php to:
'Cartalyst\Sentry\Laravel\SentryServiceProvider',

Resources