Remove package from laravel-6.2 existing project an error occurred - laravel

Remove pragmarx/tracker package from laravel project by the following composer command
composer remove pragmarx/tracker
It's remove successfully but the below error shown. Even though composer update the error not fix.
Illuminate\Contracts\Container\BindingResolutionException
Target class [PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker] does not exist.
How can I fix this error ? and which method to follow to completely remove any unused packages from laravel?

From the documentation on the repo:
Installing
Require the tracker package by executing the following command in your command line:
composer require pragmarx/tracker
Add the service provider to your app/config/app.php:
PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class,
Add the alias to the facade on your app/config/app.php:
'Tracker' => 'PragmaRX\Tracker\Vendor\Laravel\Facade',
Publish tracker configuration:
Laravel 4
php artisan config:publish pragmarx/tracker
Laravel 5
php artisan vendor:publish --provider="PragmaRX\Tracker\Vendor\Laravel\ServiceProvider"
Enable the Middleware (Laravel 5)
Open the newly published config file found at app/config/tracker.php and enable use_middleware:
'use_middleware' => true,
Add the Middleware to Laravel Kernel (Laravel 5)
Open the file app/Http/Kernel.php and add the following to your web middlewares:
\PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class,
...
If you removed the package, make sure to
delete the config/tracker.php file
remove the line PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class from config/app.php
remove the line 'Tracker' => 'PragmaRX\Tracker\Vendor\Laravel\Facade', from config/app.php
remove the line \PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class, from app/Http/Kernel.php

Related

no php artisan commands are working after new migration

I am new to laravel .
Following tutorial videos on laracast,i made a new migration (cmd command) like following
php artisan make:migration delete_title_from_posts_table
which gave me the message
Created Migration: 2020_02_05_185721_delete_title_from_posts_table
after that no php artisian command is working in cmd.
Any command i run gives me the following error
In Container.php line 805:
Target class [db] does not exist.
In Container.php line 803:
Class db does not exist
what would be causing this?
my laravel app version=6.2 and php version=7.3.5 on Win10 64-bit.
similar questions i already viewed,not working for me
artisan-commands-not-working-after-composer-update
in-container-php-line-805-target-class-db-does-not-exist
Since it's a facade, add this to the top of the class to make it work:
use DB;
Or use full namespace:
$tables = \DB::table...
run these commands steps by step:
composer dump-autoload clean up all compiled files and their paths
composer update --no-scripts Skips execution of scripts defined in composer.json
composer update update your project's dependencies

created serviceprovider then removed the file manually and am getting error

I created this provider:
php artisan make:provider ShortcodesServiceProvider
I then had to delete the file, but am now getting
FatalThrowableError in C:\xampp\htdocs\listagram\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php line 146:
Class 'App\Providers\ShortcodesServiceProvider' not found
How do I reset serviceproviders after manually deleting the provider file I created?
You should delete bootstrap/cache/services.php file manually and run composer dumpauto command to fix this.

Laravel 5.4: What is the best way to create routes based on user logged in or logged out

So, I have an API endpoint /api/v1/xxx that calls a single controller and method.
In the routes/api.php I have added the following logic
if (Auth::guard('api')->guest()) {
Route::post('xxx', 'API\v1\XXController#xx');
} else {
Route::post('xxx', 'API\v1\XXController#xx')->middleware('auth:api');
}
Everything works except when I run composer install, I get the following error:
a#b /var/www/html/test/app13 $ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
[LogicException]
Key path "file:///var/www/html/test/app13/storage/oauth-public.key" does not exist or is not readable
Script php artisan optimize handling the post-install-cmd event returned with error code 1
Removing the lines in routes/api.php does not output that ^ error when I run composer install.
What am I doing wrong?
Thanks for any help.
Key path "file:///var/www/html/test/app13/storage/oauth-public.key" does not exist or is not readable
This above lines says everything, you have laravel/passport installed and enabled but you forget to generate the key,
run command
php artisan passport:install
and it will work just fine.

Can not start laravel after trying to install library

I have web-app on Laravel and I tried to update yajra/datatables to last version, so it needed
'Maatwebsite\Excel\ExcelServiceProvider'
I tried composer update, so it didn't help.
Now I removed this line from composer.json
But on calling php artisan clear-compiled
It shows me an error:
PHP Fatal error: Class 'Maatwebsite\Excel\ExcelServiceProvider' not found in /var/www/html/talimger.xyz/vendor/laravel/framework/src/Illuminate/Foundation/Application.php on line 575
Show where I should remove this Maatwebsite files
`
The instructions at https://github.com/Maatwebsite/Laravel-Excel tell you what to do, but not how to do it. The assumption is that you already know a bit about composer.
Here's the 'how to do it'...
1) Remove the service provider entries you made and delete any lines you added to composer and then type the following:
composer require "maatwebsite/excel"
2) After updating composer, add the ServiceProvider to the providers array in config/app.php
Laravel 5.1:
'Maatwebsite\Excel\ExcelServiceProvider',
Laravel 5.2:
Maatwebsite\Excel\ExcelServiceProvider::class,
3) You can use the facade for shorter code. Add this to your aliases:
Laravel 5.1:
'Excel' => 'Maatwebsite\Excel\Facades\Excel',
Laravel 5.2:
'Excel' => Maatwebsite\Excel\Facades\Excel,::class
Comment out 'Maatwebsite\Excel\ExcelServiceProvider' from the providers array in app.php under config then run composer update when you are done then your uncomment it.

laravel PackageServiceProvider not found; moving from workbench to vendor

This is basically a problem of moving a laravel package from workbench to vendor, but the solutions in other threads have not worked in this case:
I have a package iateadonut/signup.
I created a fresh laravel installation (laravel_test), and, just for testing sake, I put iateadonut/signup in laravel_test/workbench/.
I put Iateadonut\Signup\SignupServiceProvider, in the 'providers' array in app.php.
I then run:
/laravel_test> php artisan dump-autoload
and get:
Generating optimized class loader
Running for workbench [iateadonut/signup]...
My package is successfully installed.
On a fresh installation of laravel (laravel_test), I then put iateadonut/signup in larael_test/vendor.
I put Iateadonut\Signup\SignupServiceProvider, in the 'providers' array in app.php.
I then run:
/laravel_test> php artisan dump-autoload
and get:
PHP Fatal error: Class 'Iateadonut\Signup\SignupServiceProvider' not found in /var/www/html/laravel_test/bootstrap/compiled.php on line 4214
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'Iateadonut\Signup\SignupServiceProvider' not found","file":"/var/www/html/laravel_test/bootstrap/compiled.php","line":4214}}
Any idea what could be wrong?
Here is a more google friendly version in case someone else is looking for this:
PHP Fatal error: Class 'Vendor\Package\PackageServiceProvider' not found in /var/www/html/laravel/bootstrap/compiled.php on line 4214
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'Vender\Package\PackageServiceProvider' not found","file":"/var/www/html/laravel/bootstrap/compiled.php","line":4214}}
Try to remove the the bootstrap/compiled.php file and try your composer dumpautoload again

Resources