简体   繁体   English

开发 Laravel 包 - 如何访问 artisan 命令

[英]Developing Laravel Package - How to access artisan commands

I have been working on a new Laravel package where I've manually created the directory structure then manually make the controllers and then add my package into a main laravel 8 project which all works fine but when developing the package you don't have access to the artisan commands to quickly scaffold some of the code.我一直在研究一个新的 Laravel 包,我手动创建了目录结构,然后手动制作控制器,然后将我的包添加到主要的 Laravel 8 项目中,这一切正常,但是在开发包时,您无权访问工匠命令快速搭建一些代码。

Plus the IDE (PHP Storm in my case) doesn't know what any of the laravel methods are so it thinks the code is wrong and there's no auto complete available and you don't have access to the artisan command to automatically scaffold controllers, requests migrations etc, so you lose a lot of the benefits of Laravel and the IDE when developing a package.另外,IDE(在我的例子中是 PHP Storm)不知道任何 Laravel 方法是什么,所以它认为代码是错误的,并且没有可用的自动完成功能,并且您无权访问 artisan 命令来自动搭建控制器,请求迁移等,所以在开发包时你会失去 Laravel 和 IDE 的很多好处。

Is there a way to add something to the package and/or the IDE to make this functionality available.有没有办法在包和/或 IDE 中添加一些东西来使这个功能可用。 I've looked at the package scaffolders available at https://laravelpackage.com/#tools-and-helpers but they all seem to be somewhat broken, or just create the basic directory structure and not provide the artisan commands or using old versions of Laravl or PHP 7. I am using Laravel 8 and PHP 8.我查看了https://laravelpackage.com/#tools-and-helpers上提供的包脚手架,但它们似乎都有点损坏,或者只是创建基本目录结构而不提供工匠命令或使用旧版本Laravel 或 PHP 7 的版本。我使用的是 Laravel 8 和 PHP 8。

For comfortably package developing you need Orchestra Testbench为了舒适地进行软件包开发,您需要Orchestra Testbench

Just install it with --dev and you can access to all laravel features in development process.只需使用--dev安装它,您就可以在开发过程中访问所有 Laravel 功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM