laravel artisan tool to generate mvc structure - php

I used cakephp before and it comes with bake command tool that generate full MVC skeleton with complete crud functions.
Cakephp's bake console just need database to read and it automatically generate the code with command:
bake all --everything
I want to know dose atrisan have the same tool or not? And if so how can I do that?
Should I install third party packages to achieve this or Laravel artisan support by default?
I prefer laravel default tooling if its available.
Thanks in advance.

I don' think there is a built in command like bake all in laravel. However this library seems to do what you are asking for
You can use artisan to create individual MVC components. Perhaps you could collect these in a shell script and run them all at the same time
Creating a controller
This will also generate the crud functions
php artisan make:controller ControllerName
Creating a model
php artisan make:model ModelName

Related

is php artisan make::controller required for Laravel development?

I'm starting out learning Laravel, and all the tutorials show how to use
php artisan make:controller BlahController
to make a new controller.
Is there a requirement I do this from the command line? If I want to do it by hand, what would I need to do to replicate that action?
I know that of course, I'd need to manually create the BlahController.php file inside the app\http\Controllers folder.
But does artisan make:controller alter/create any other files?
Broader question. Is php artisan required at all to work in Laravel? Or can all development be done by hand coding?
No, it is not required at all to use php artisan to create any files.
The purpose of artisan is to make your work more automated or less coding in general, but you are 100% correct, you can just manually create the controller file on its own (or model or view or anything related to laravel) without using artisan.
Example of artisan is to do things like:
php artisan create:model MyModel -all
This will create:
migration
seeder
factory
policy
resource controller
form request classes for the model
all of that is created and ready to be edited in a single command rather than having to manually create each file and filling it up and checking if the names are correct etc...
You can do so many things with artisan to simplify the process, and you can always read more on what options you have when creating things by doing:
php artisan create:controller -help
More of the documentation can be found here: https://laravel.com/docs/9.x/artisan#introduction
Laravel artisan helps you to do things faster
Ofcourse you can create it manually but artisan makes your life a little bit easier!
I highly recommend it
Also It's not about just creating a controller
It does a lot, read more about it here:
https://laravel.com/docs/9.x/artisan

How to use Jenssegers\Mongodb\Eloquent\Model instead of Illuminate\Database\Eloquent\Model in php artisan make:model command

I'm developing a webapp with Laravel and MongoDB (jenssegers/laravel-mongodb).
While creating a new model with php artisan make:model, the command uses Illuminate\Database\Eloquent\Model declaration in the file and every time I need to replace Illuminate\Database\Eloquent\Model with Jenssegers\Mongodb\Eloquent\Model manually.
Is there a way to automate the process?
It doesn't look like the package provides an Artisan command to create a MongoDB model stub, which seems like a bit of an oversight. However, it's not terribly hard to create this kind of generator command for Artisan yourself if you need it.
The model make command is at https://github.com/laravel/framework/blob/5.7/src/Illuminate/Foundation/Console/ModelMakeCommand.php and the stub file used to create it is at https://github.com/laravel/framework/blob/5.7/src/Illuminate/Foundation/Console/stubs/model.stub. If you extend the command class to replace the stub file with your MongoDB version, and amend the stub file to be a MongoDB model, then you should be able to create a command for generating MongoDB models. It might even be worth forking the package to add this and submitting a pull request to get it added to the package. I would refer to the part of the Laravel documentation that deals with Artisan for more details, as that describes the process of adding your own Artisan commands in detail.
Another approach would be to write your own class generator and then overwrite the command make:model
Add the following in the file routes/console.php to override the command
use Path\To\Class\MyCustomClassGenerator;
Artisan::command('make:model', function(){
new MyCustomClassGenerator();
$this->comment('new MongoDB Model generated');
});

Laravel 5.4: How to add service layer files?

I need to add service layer in my project where controllers are doing all work now.
Can I use PHP artisan to make service files, as we do for controllers: php artisan make:controller ?
How do you add service files?
I'll leave an answer just in case someone is also looking for it.
No, there is not such thing as service layer out of the box in Laravel, you should either implement it yourself or you can require a repository which implements it https://github.com/TakeoO/laravel-service-layer

OctoberCMS Migrate Table

I am very new to octobercms and I have experience in using laravel 4.2 .
I wanna ask how to create a table using artisan in cmd? Or is it in octobercms does not need to use cmd to create table? Any link with details tutorial to share?
Thank you.
First, you need to create a plugin : php artisan create:plugin MyCompagny.MyPlugin
Then, you can create a model (table) : php artisan create:model MyCompagny.MyPlugin Nameofthemodel
Then you can edit the migration file to fit your need, and run php artisan plugin:refresh MyCompagny.MyPlugin
Note that OctoberCMS is based on Laravel 5.0
That's it! Hope its help
Though the above answer is correct, another solution for creating tables would be using Rainlab.Builder plugin, which has its own user interface to easily create tables, Models, Controllers and many more )

Creating a mysql view using php artisan for migration?

How do you create a mysql view using php artisan? Can't find any documentation on it???
Google and Bing aren't returning much at all!
documentation for Laravel: http://laravel.com/docs/migrations
Your question is a little unclear. It seems you may not understand the difference between Views, Migrations and MySQL Tables.
Migrations can be created with Artisan via php artisan make:migration ... or manually. They contain code that create MySQL Tables.
Views are template files that display a page for end users to interact with. In Laravel, Views are Blade Templates.
Artisan does not offer a command for creating Views. But there are Composer packages you can install that will extend Artisan with such functionality.
https://github.com/bencomeau/artisan-make-view
https://github.com/svenluijten/artisan-view

Categories