PHP artisan vendor:publish 命令执行完毕,但是并没有生成配置文件?[已解]

即使先运行php artisan cache:clear清除缓存也不行,虽然php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravel5"提示执行完成,但是config目录下面并没有生成配置文件image.php

没办法,只能从vendor目录里面强行复制一份配置文件到config目录里了,并改名为image.php,可惜无效!修改这份手工复制的文件,再使用config('image')检测,发现修改后的设置根本就不存在。
PHP artisan vendor:publish 命令执行完毕,但是并没有生成配置文件?
倒!终于解决!!
PHP artisan vendor:publish 命令执行完毕,但是并没有生成配置文件?
诀窍如下:
1、使用 vendor:pulish 命令时不要指定provider!!防止版本升级掉坑里。直接手工选择数字即可!(要删掉之前的才会发布新的)
2、修改配置文件后要使用命令 php artisan config:clear 清除一下!使用 cache:clear 命令是不行的。

即使不用 vendor:pulish 命令,强行复制一份文件到config目录里并设置正确的文件名,应该也是可行的。我前面一直无效,是因为没有使用命令 config:clear清除旧配置(懒得测试了,因为配置文件已经发布成功)。


感谢 largezhou 指点迷津,这才解决了这个问题。谢谢!

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
最佳答案

算是找到解决办法了,由于版本更新,使用ImageServiceProviderLaravel5已经不能发布了,要改成ImageServiceProviderLaravelRecent才能发布。干脆不写提供者,直接输入数字选择更好!注意:要先删掉旧的image.php文件才会发布新文件(如下图)。
但是,问题仍然存在:尝试修改'driver' => 'imagick'然后tinker测试修改结果仍然没有生效?
file

4年前 评论
zhaiduting (作者) (楼主) 4年前
讨论数量: 8

找不到解决办法,最后只能打开vendor目录强行复制了一份配置文件到config目录下(改名为image.php了)……话说强扭的瓜不甜,这强行拷贝的文件还不知道行不行
file

4年前 评论

强扭的瓜果然不行啊!如下图所示,配置文件里面的driver明明已经被我改成了imagick,可是tinker里面显示的还是gd,还有我额外增加的最大宽度值也没了……看来还得使用vendor:publish命令才行
file

4年前 评论
largezhou 4年前
largezhou 4年前
zhaiduting (作者) (楼主) 4年前
zhaiduting (作者) (楼主) 4年前
zhaiduting (作者) (楼主) 4年前

哦,这次清除缓存了,一样发布不了配置文件

D:\www\laravel55.bbs> php artisan cache:clear
Cache cleared successfully.

D:\www\laravel55.bbs>php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravel5"
Publishing complete.

file

4年前 评论

如下图,只能选择第5项[5] Provider: Intervention\Image\ImageServiceProviderLaravelRecent
file
整个过程如下

D:\www\laravel55.bbs>php artisan cache:clear
Cache cleared successfully.

D:\www\laravel55.bbs>php artisan vendor:publish

 Which provider or tag's files would you like to publish?:
  [0] Publish files from all providers and tags listed below
  [1] Provider: Fideloper\Proxy\TrustedProxyServiceProvider
  [2] Provider: Illuminate\Mail\MailServiceProvider
  [3] Provider: Illuminate\Notifications\NotificationServiceProvider
  [4] Provider: Illuminate\Pagination\PaginationServiceProvider
  [5] Provider: Intervention\Image\ImageServiceProviderLaravelRecent
  [6] Provider: Laravel\Tinker\TinkerServiceProvider
  [7] Tag: laravel-mail
  [8] Tag: laravel-notifications
  [9] Tag: laravel-pagination
 > 5
5[K

Publishing complete.

D:\www\laravel55.bbs>php artisan tinker
Psy Shell v0.9.11 (PHP 7.3.5 — cli) by Justin Hileman

>>> config('image')
=> [
     "driver" => "gd",
   ]
>>>

实际上,我的配置文件应该显示下面这样的才对

[
    'driver' => 'imagick',
    'avatar_max_width' => 300,
];

总之,问题出在了vendor:publish命令上了,无效的。改用laravel 5.8测试,也没效果。

4年前 评论

哦!我知道了,问题不是出在命令上面,而是出在 intervention/image 这个插件上了,它根本就发布不了!版本问题?
我改用php artisan vendor:publish --provider=Laravel\Tinker\TinkerServiceProvider这个就可以正常发布!虽然发布的东西不是我想要的。但是这说明:vendor:publish命令是正常的(只要provider没问题就可以发布的,而且不需要用引号包裹的)。
Laravel
估计是Intervention\Image\ImageServiceProviderLaravelRecent文件有问题,改用其他的一律无效

D:\www\laravel55.bbs>php artisan vendor:publish --provider=Intervention\Image\ImageServiceProvider
Publishing complete.

D:\www\laravel55.bbs>php artisan vendor:publish --provider=Intervention\Image\ImageServiceProviderLaravel
Publishing complete.

D:\www\laravel55.bbs>php artisan vendor:publish --provider=Intervention\Image\ImageServiceProviderLaravel5
Publishing complete.

D:\www\laravel55.bbs>php artisan vendor:publish --provider=Intervention\Image\ImageServiceProviderLaravelRecent
Publishing complete.

版本如下(Win7 64位,PHP7)

        "intervention/image": "^2.5",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "~1.0",
4年前 评论

算是找到解决办法了,由于版本更新,使用ImageServiceProviderLaravel5已经不能发布了,要改成ImageServiceProviderLaravelRecent才能发布。干脆不写提供者,直接输入数字选择更好!注意:要先删掉旧的image.php文件才会发布新文件(如下图)。
但是,问题仍然存在:尝试修改'driver' => 'imagick'然后tinker测试修改结果仍然没有生效?
file

4年前 评论
zhaiduting (作者) (楼主) 4年前

这下问题跟vendor:publish命令无关了,而是修改任意一个配置文件都无效……我之前的时区设置的是 PRC 我尝试将其改回 UTC,然后清除缓存,最后使用tinker测试:修改无效!仍然是PRC
file

4年前 评论
zhaiduting (作者) (楼主) 4年前
largezhou 4年前
zhaiduting (作者) (楼主) 4年前

laravle 5.8 直接选择数字发布配置文件有效果,见图

file

file

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!