Comments (14)
Auto detecting commands is easy. Here's some code lifted from from kernel of an app I have:
/**
* Get the artisan application instance.
*
* @return \Illuminate\Console\Application
*/
protected function getArtisan()
{
if (!$this->artisan) {
$this->artisan = new Application($this->app, $this->events, $this->app->version());
// put any other commands in this array
// in this case, the deploy command here is Bugsnag\BugsnagLaravel\Commands\DeployCommand
$commands = [DeployCommand::class];
foreach (glob(app_path('Console//Commands').'/*.php') as $file) {
$commands[] = 'App\\Console\\Commands\\'.basename($file, '.php');
}
$this->artisan->resolveCommands($commands);
}
return $this->artisan;
}
from laravel-zero.
@jkniest I am definitely interested in that.
That means, all commands in the app/Commands directory (the file path would be configurable) would be registered automatically without the need to register them manually in the config file.
This should be an array of directories on the config. Any none, the framework will automatically assign app/Commands
.
I will leave this issue open while we wait for the development. Thanks for the help!
from laravel-zero.
@jkniest your right, I did mix the two up 😄
Should really read and understand before posting 😆
from laravel-zero.
@jkniest I will see! Thanks for the feedback!
from laravel-zero.
Ok, cool.. I will start this evening with the development :)
from laravel-zero.
This feature just got implemented in: laravel-zero/framework@dec0346 👍
from laravel-zero.
WANTED 😄
from laravel-zero.
Makes sense for me. 👍 @nunomaduro your thoughts?
from laravel-zero.
Note that this is not exactly high performance, but fast enough if you don't have many commands, and if you don't care about bootstrapping time, compared to with http where you might.
The performant way to do this would be to have a command that cached the classes to register, similar to how route caching works in the core framework.
from laravel-zero.
I agree with the performance part but the caching commands would add new documentation and explanation, because many users will be confused (at first) why there old commands are still running, even if their not in the $command array anymore (because their cached).
As an alternative, we could make the auto detection optional. For example a bool value in the config file, wether they want to use it..
I think in most console application's it doesn't matter much, because they don't have that much commands and if they do have so many, they could simply remove the folder from the detection-array and register all commands manually.
What are your thoughts?
from laravel-zero.
I would of thought this would be similar to Laravel 5.5 package autoload that parses the composer/installed.php so when you add a new package through composer the post update script will trigger a command to rebuild the cache.
This would be additional to the current way of adding commands.
from laravel-zero.
@ashleyhood Yeah.. but in the current state laravel loads all commands when the application starts, not when composer is updating / dumping the autoload.
I think you are mixing here two different features: Package autoloading & Command autoloading :)
from laravel-zero.
@jkniest Do you have news on this? Otherwise I don't mind of implementing this. 😊
from laravel-zero.
Oh sorry.. I haven't much time in the last days.. Feel free to implement this feature.. :-)
from laravel-zero.
Related Issues (20)
- New Project doesn't work "Undefined variable $command" HOT 2
- [BUG] self-update from github releases not working HOT 1
- Cannot find sqlite database when upgrading HOT 3
- app:build ErrorException rename(app.phar, builds/app): the system cannot find the file specified (code 2) HOT 3
- Failing builds: "database/factories" and "database/seeders" was expected to exist HOT 1
- app:build gives the error: The system cannot find the file specified (code: 2) HOT 4
- Why is package auto-discovery is off ? HOT 4
- Site https://laravel-zero.com is down HOT 1
- website down/expired. Is this project still being worked on? HOT 1
- Website is down - domain expired? HOT 3
- laravel-zero.com is down HOT 1
- Website is not working anymore http://laravel-zero.com/ HOT 3
- Global Composer installation without commiting binary to version control?
- Using DB pagination methods inside a command throws an exception HOT 1
- On Windows, when running app:build "impossible find specified file" HOT 5
- QUEUES Call to undefined method Psr\Log\NullLogger::driver()
- Composer Warnings when installing pest-plugin-laravel HOT 3
- Can't update phpunit because of nunomaduro/collision version in the composer.json HOT 1
- console command suggestion
- DB related command appears when installing larastan HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-zero.