How to delete laravel built-in two migration files? - laravel

I am using laravel 5.2. I want to delete two laravel built-in migration files 2014_10_12_000000_create_users_table.php and 2014_10_12_100000_create_password_resets_table.php. But PhpStorm told me that there are two usages in other files' code. So if I delete them, I first delete two files' usages, and then delete two files, is that right?

First of all, check in your migrations table if the file is migrated. If its migrated you can use: php artisan migrate:rollback.
You can delete the files, after that you can run: composer dump-autoload, this will recreate all the files generated by composer.
Hope this works!

If you've already ran migrate command, run php artisan rollback. Then delete these two files and run composer dumpauto

Related

Is there a way to fix missing files of laravel 5.6

Some guy made a site with laravel 5.6 and we at a different place need to change just some tags and the CSS, I have a git of the site but "vendor, .env" and many files that are also missing in the git, how can I open the site in my computer to adjust the style sheets I have no database backup and also installed laravel 5.6 and try to paste de missing files but there are still many errors.
Altough the original programmers excluded some files in the git repo using the ignoregit file I created a new laravel 5.6 project and copied the missing files to my original app folder, imported the missing packages using composer and finally used artisan to migrate the database using "php artisan migrate"

is laravel 5.4 running migrations from vendor folders now?

I have installed some packages that have migrations in their vendor folders, previously one of the packages I used published these migrations to migrations folder by running:
php artisan vendor:publish
Now I found alteast 2 packages that no longer published migrations when running this command, so I went into vendor folder and grabbed migration file and manually moved it and when I run
composer dump-autoload I got a warrning message from it that said: Warning:
Ambiguous class resolution, "CreateRevisionsTable" was found in both "$baseDir . '/database/migrations/2013_04_09_062329_create_revisions_table.php" and "C:\xampp\htdocs\example\vendor/venturecraft/revisionable/src/migrations\2013_04_09_062329_create_revisions_table.php", the first will be used.
why is this happening? Has something changed in 5.4?
Yes, since version 5.4 Laravel supports loading migrations from any directory.
$this->loadMigrationsFrom(__DIR__.'/path/to/migrations');
Which could be used by a service provider of any package.

Laravel deleting package with composer

I tried to delete barryvdh/laravel-debugbar from my laravel installation, and it seems I didn't make something right.
What I did so far :
composer remove barryvdh/laravel-debugbar
I deleted then the references in config/app.php
And I've got an error :
[RuntimeException]
Error Output: PHP Fatal error:
Class 'Barryvdh\Debugbar\ServiceProvider' not found in
{mypath}\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php on line 146
I tried dump-autoload, clear-compiled, but none works.
What did I miss ?
22/02/2016 Edit : I also tried to remove ALL the vendor folder, then install it again via composer install, but I got the error again when the command php artisan clear-compiled was run angain.
Ok, it seems I had played with artisan commands, and the configuration file was cached (via php artisan config:cache).
I deleted it (in bootstrap/cache/config.php) and everything works like a charm, but I also could have used the command php artisan config:clear to remove it.
When you installed Debugbar, after the package was install via composer you needed to add the class to the providers array in config/app.php. So you need to remove this line from there:
Barryvdh\Debugbar\ServiceProvider::class
If you also register the facade, then you need to remove the following from the aliases array from the same file:
'Debugbar' => Barryvdh\Debugbar\Facade::class
If you also ran php artisan vendor:publish (which is the final step described in the Installation Section from the package readme) then you can delete the config/debugbar.php file as well, although leaving that configuration file in place will not cause any issues.
Marc Brillault's answer is correct. I am adding more clarification to that answer:
I removed debug bar class manually from the catch files. present in (bootstrap/cache/config.php).
Steps for How to remove manually class.
1.) Open this two files
`bootstrap/cache/config.php`
`config/app.php`
2.) Find this two line and remove It.
Barryvdh\Debugbar\ServiceProvider::class,
'Debugbar' => Barryvdh\Debugbar\Facade::class,
3.) run command `php artisan config:clear`
after the following this step check command php artisan list is working well.
you must:
First. Delete the references to Debugbar in config/app.php
Second. composer remove barryvdh/laravel-debugbar
In that order. If you don't, Laravel get confused ;)
The best ways you need to do is delete all file manually in all composer files.

How can I remove a package from Laravel using PHP Composer?

What is the correct way to remove a package from Laravel using PHP Composer?
So far I've tried:
Remove declaration from file composer.json (in the "require" section)
Remove any class aliases from file app.php
Remove any references to the package from my code :-)
Run composer update
Run composer dump-autoload
None of these options are working! What am I missing?
Composer 1.x and 2.x
Running the following command will remove the package from vendor (or wherever you install packages), composer.json and composer.lock. Change vendor/package appropriately.
composer remove vendor/package
Obviously you'll need to remove references to that package within your app.
I'm currently running the following version of Composer:
Composer version 1.0-dev (7b13507dd4d3b93578af7d83fbf8be0ca686f4b5) 2014-12-11 21:52:29
Documentation
https://getcomposer.org/doc/03-cli.md#remove
Updates
26/10/2020 - Updated answer to assert command works for v1.x and v2.x of Composer
I got it working... The steps to remove a package from Laravel are:
Remove the declaration from file composer.json (in the "require" section)
**Remove Service Provider from file config/app.php (reference in the "providers" array)
Remove any class aliases from file config/app.php
Remove any references to the package from your code :-)
Run composer update vendor/package-name. This will remove the package folder from the vendor folder and will rebuild the Composer autoloading map.
Manually delete the published files (read the comment by zwacky)
It will remove the package folder from the Vendor folder.
Normally composer remove used like this is enough:
composer remove vendor/package
But if a Composer package is removed and the "config" cache is not cleaned you cannot clean it. When you try like so
php artisan config:clear
you can get an error In ProviderRepository.php line 208:
Class 'Laracasts\Flash\FlashServiceProvider' not found
This is a dead end, unless you go deleting files:
rm bootstrap/cache/config.php
And this is Laravel 5.6 I'm talking about, not some kind of very old stuff.
It happens usually on automated deployment, when you copy files of a new release on top of old cache. Even if you cleared the cache before copying. You end up with an old cache and a new composer.json file.
You can remove any package just by typing the following command in the terminal, and just remove the providers and alias you provided at the time of installing the package, if any and update the composer,
composer remove vendor/your_package_name
composer update
Before removing a package from a composer.json declaration, please remove the cache:
php artisan cache:clear
php artisan config:clear
If you forget to remove the cache and you get a "class not found error" then please reinstall the package, clear the cache and remove again.
You can do any one of the below two methods:
Running the below command (most recommended way to remove your package without updating your other packages)
$ composer remove vendor/package
Go to your composer.json file and then run command like below it will remove your package (but it will also update your other packages)
$ composer update
If you are still getting the error after you are done with all the steps in the previous answers, go to your projects, Bootstrap → Cache → config.php. Remove the provider and aliases entries from the cached array manually.
Use:
composer remove vendor/package
This is an example:
Install or add a package
composer require firebear/importexportfree
Uninstall / remove
composer remove firebear/importexportfree
Finally after removing:
php -f bin/magento setup:upgrade
php bin/magento setup:static-content:deploy –f
php bin/magento indexer:reindex
php -f bin/magento cache:clean
Running
Composer remove package/name
Php artisan optimize
e.g "Composer remove mckenziearts/laravel-notify" works for me while using Laravel 8.
To add the packages, the command is to be like:
composer require spatie/laravel-permission
To remove the packages, the command is to be like:
composer remove spatie/laravel-permission
In case the given answers still don't help you remove that, try this:
Manually delete the line in require from composer.json
Run composer update
If this doesn't work "composer remove package/name", you can still remove it manually.
Note : package/name is like spatie etc.
Go to composer.json and find the package name
Delete package name from composer.json
Find the vendor file in your Laravel project.
Delete the package file which is under vendor
run composer install on your terminal
Note : Package File mean is that package that you are looking for. For example, you want to remove Spatie. Then you need to find that with similar name in vendor file and you need to delete it manually.
Your package was removed successfully.
We have come with a great solution. This solution is practically done in Laravel 6. If you want to remove any package from your Laravel Project then you can easily remove the package by following below steps:
Step 1: You must know the package name which you want to remove. If you don't know the complete package name then you can open your project folder and go to the composer.json file and check the name in the require array:
"require": {
"php": "^7.2",
"fideloper/proxy": "^4.0",
"laravel/framework": "^6.2",
"laravel/passport": "^8.3",
"laravel/tinker": "^2.0"
},
Suppose, here I am going to remove the "fideloper/proxy" package.
Step 2: Open a command prompt with your project root folder directory
Step 3: First of all, clear all cache by the following commands. Run the commands one by one.
php artisan cache:clear
php artisan config:clear
Step 4: Now write the following command to remove the package. Here you need to change your package name instead of my example package.
composer remove fideloper/proxy
Now, wait for a few seconds while your package is removed.
On Laravel 8.*, the following steps work for me:
Run command composer remove package-name on the terminal
Remove Provider and aliases from file Config/app.php
Remove the related file from the Config folder.
Remove it from your code where you used it.
Remove the package folder from the vendor folder (manual delete)
Remove it from file composer.json and 'composer.lock' files (use Ctrl + F5 to search)
Remove it from file config/app.php and file bootstrap/cache/config.php files
Run these commands:
composer remove **your-package-name**
php artisan cache:clear
php artisan config:clear
There are quite a few steps here:
Go to file composer.json and look for the package and how it is written over there.
for example
{ "require": {
"twig/twig": "^3.0" } }
I wish to remove twig 3.0
Now open cmd and run composer remove vendor/your_package_name as composer remove twig/twig will remove the package.
As a final step, run composer update. This will surely give you a massage of nothing to install or update, but this is important in case your packages have inter-dependencies.
You have two solution.
First
Use remove of composer.
composer remove *your_package_name*
Second
Delete the line in require from composer.json and then run update
composer update
After removed, recommend to run below two command.
php artisan cache:clear
php artisan config:clear

Laravel 4: php artisan down not defined

I've updated my Laravel installation with the following commands today (which is a few days after Laravel 4's release date):
php composer self-update
php composer update
You can have a look at my composer.json file here: http://paste.laravel.com/umX
In the Docs I've found out about the Maintenance Mode... (http://laravel.com/docs/configuration#maintenance-mode) Trying to use it returns:
[InvalidArgumentException]
Command "down" is not defined.
Command I've entered in the terminal for this exception:
php artisan down
My current version:
php artisan --version
Laravel Framework version 4.0.0
Any ideas? Did i miss something, am I still on some old version possibly?
Thanks in advance and best regards, Martin.
The fix for me was to update the 'providers' array in ./app/config/app.php. I thought I was doing a pretty good job of manually updating the L4 skeleton near the end of the beta period, but there was a minor change in that array (not sure which line) that allowed the 'down' command to finally appear in artisan.
The first thing I suggest you do is just run php artisan list to get a list of all the available commands. If the up and down commands aren't listed then you probably aren't fully updated.
If you have a bootstrap/compiled.php file try deleting it. Also make sure you pull the latest changes in from the laravel/laravel GitHub repository to update your application skeleton.
Once you've done the above you can again check for the existence of the commands by running php artisan list.
In app/start/global.php (or app/start/artisan.php), you need:
App::down(function() { return Response::make("Be right back!", 503); });
don't you?
Perhaps you could also try updating laravel via composer "composer update" in CLI.
I've just installed a clean Laravel 4 clone and tryed the maintenance mode with it.
Everything's working as supposed...
I've also compared the composer.json files + I'm pretty sure I've done nothing wrong updating to the stable release version even thought my app/start/* php-files remain unchanged.
Summary:
Composer seems to not override the php files in app/start/* which would be needed in order to get the maintenance mode working correctly. Probably there are even more files not being updated. This also makes a lot of sense, since you could have done some important customizations to your application there.
Correct me if I'm wrong... I'll start importing my package into a clean install thought. Don't want to run into more trouble due to this.
Best Regards, Martin.

Resources