php 如何清理 Laravel Bootstrap 缓存配置文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33823207/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:38:02  来源:igfitidea点击:

how to clean Laravel Bootstrap cache config file?

phpmysqllaravel

提问by Abel D

I developed laravel app locally and uploaded in shared hosting.

我在本地开发了 Laravel 应用程序并上传到共享主机。

While hosting I changed the database name and username of mysql in the .env and the config/database files.

在托管时,我在 .env 和 config/database 文件中更改了 mysql 的数据库名称和用户名。

But in remote its still using the old db name and user which is found in the bootstrap/cache/config file.

但是在远程它仍然使用在引导/缓存/配置文件中找到的旧数据库名称和用户。

So how to clean the bootstrap/cache/config.php file?

那么如何清理 bootstrap/cache/config.php 文件呢?

采纳答案by P??

Use php artisan cache:clearto flush the application's cache.

使用php artisan cache:clear冲洗应用程序的缓存。

回答by Tommy May

If you are trying to clear configuration cache, which it sounds like you are. You need to run:

如果您正在尝试清除配置缓存,这听起来像您一样。你需要运行:

php artisan config:clear

php artisan config:clear

At some point, you probably ran php artisan config:cachewhich generated a cached version of your config file, and this file is notcleared with php artisan cache:clear

在某些时候,您可能运行php artisan config:cache它生成了配置文件的缓存版本,并且该文件没有被清除php artisan cache:clear

回答by Rahul

I tried all the above options but nothing works.

我尝试了上述所有选项,但没有任何效果。

I manually removed from bootstrap/cache/config.php. And it works. This is the Ultimatesolution.

我手动从 bootstrap/cache/config.php 中删除。它有效。这是终极解决方案。

回答by Juha Vehnia

I just stumbled into this while building automated deployment in AWS. The problem with Laravel is that artisan commands also use the cache. Now if you deploy new version of your application you may have outdated entries in the cache which in turn will make the artisan command to crash i.e. cannot find some class that was cached but no longer exist. Therefore you either need to:

我只是在 AWS 中构建自动化部署时偶然发现的。Laravel 的问题在于 artisan 命令也使用缓存。现在,如果您部署应用程序的新版本,您可能在缓存中有过时的条目,这反过来会使 artisan 命令崩溃,即无法找到某些已缓存但不再存在的类。因此,您要么需要:

1) Clear cache before you deploy the application

1)在部署应用程序之前清除缓存

php artisan cache:clear

2) Clear cache manually

2)手动清除缓存

rm -fr bootstrap/cache/*

Finally you want to run optimize command which will re-build your configuration cache, bootstrap file cache and route caches.

最后,您要运行优化命令,该命令将重新构建您的配置缓存、引导文件缓存和路由缓存。

php artisan optimize

回答by Lucas Bustamante

php artisan config:clear

Or you can just manually delete bootstrap/config.php, which is what artisan does after all.

或者你可以手动删除bootstrap/config.php,这毕竟是 artisan 所做的。

See: vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigClearCommand.php

参见:vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigClearCommand.php

回答by Ajit Kumar Singh

You can use:

您可以使用:

Laravel 4 : php artisan cache:clear

拉维尔4: php artisan cache:clear

also for laravel 5(not tested),

也适用于 Laravel 5(未测试),

Illuminate\Cache\FileStorehas the function flush

Illuminate\Cache\FileStore有这个功能 flush

Cache::flush();

also,

还,

use Doctrine\Common\Cache\CacheProvider as DoctrineCache;

DoctrineCache::flushAll();

回答by Kiran Maniya

Here is the Tip,

这里是提示,

  1. Flushing Application cache

    • Use php artisan cache:clearto flush the application cache or php artisan cache:forgetto discard specific cache.
    • You can use php artisan config:clearto clear cached configuration of application.
  2. Removing Blade Templates cache

    You can use php artisan view:clearto clear all compiled views.

  3. Application Bootstrap cache

    If you want to clear the application bootstraper cache, php artisan optimize:clearwill help you.

  4. Route Cache

    There also a command to clear the route cache as php artisan route:clear.

  5. Events and Listeners cache

    For events and listeners cache you can use php artisan event:clear

  1. 刷新应用程序缓存

    • 使用php artisan cache:clear刷新应用程序缓存或php artisan cache:forget丢弃特定的缓存。
    • 您可以使用php artisan config:clear清除应用程序的缓存配置。
  2. 删除刀片模板缓存

    您可以使用php artisan view:clear清除所有编译视图。

  3. 应用程序引导缓存

    如果您想清除应用程序引导程序缓存,php artisan optimize:clear将帮助您。

  4. 路由缓存

    还有一个命令可以将路由缓存清除为php artisan route:clear.

  5. 事件和侦听器缓存

    对于事件和侦听器缓存,您可以使用 php artisan event:clear

if you still stuck in finding helpful commands, you can run php artisan listand it will list out every command with its description. look for a specific thing you want to perform. if you need migration-related command, you can look in migration.

如果你仍然坚持寻找有用的命令,你可以运行php artisan list它,它会列出每个命令及其描述。寻找您想要执行的特定事情。如果需要迁移相关的命令,可以查看migration

回答by Connor Leech

The solution for me was to remove the files in the bootstrap/cache/directory and then delete the vendorfolder. Re-run composer installand then composer dump-autoloadand the above campaigns should run fine. Deleting the vendorfolder and re-running composer installwas the missing link for me

我的解决方案是删除目录中的bootstrap/cache/文件,然后删除vendor文件夹。重新运行composer install,然后composer dump-autoload上述活动应该运行良好。删除vendor文件夹并重新运行composer install是我丢失的链接