⛵laravel-generator
is administrative interface builder for laravel which can help you build code template you want as soon as possiable.
- PHP >= 7.0.0
- Laravel >= 5.5.0
Via Composer
composer require --dev foryoufeng/laravel-generator
Then run the command to publish resources and config:
php artisan vendor:publish --provider="Foryoufeng\Generator\GeneratorServiceProvider"
After run command you can find config file in config/generator.php
,and you can configure the position of the stub and the file you want to generate, the default stub will be in resources/generators
directory, in this file you can config your file.
now you can access your application http://yourhost/generator
to use the laravel-generator
the generator.php
doc
<?php
return [
'name' => 'Laravel-generator',
//the url to access
'route'=>'generator',//you can change the access url if you do not like it
'modelPath'=>'App\\Models\\', //where your models in
'views'=>[], //waiting to finish
'multiple'=>[ // to genetate multiple file
// group file
[
'name'=>'controllers', // which is the label name in the html
//The file suffix
'postfix'=>'Controller', //such as UserController,the postfix is Controller ,or UserTest the postfix is Test
'group'=>[
[
'namespace'=>'App\\Http\\Controllers\\',
'stub'=>resource_path('generators').'/controllers/home_controller.stub', //where the stub in
'isChecked'=>true //you can change it to false
],
[
'namespace'=>'App\\Http\\Controllers\\Api\\',
'stub'=>resource_path('generators').'/controllers/api_controller.stub',
'isChecked'=>true
]
],
]
],
//one file
'single'=>[ // to genetate one file
[
'name'=>'dao',
'namespace'=>'App\\Http\\Daos\\',
'stub'=>resource_path('generators').'/dao.stub',
'isChecked'=>true,
'postfix'=>'Dao'
]
],
];
<?php
namespace DummyNamespace; //which is the `namespace` you defined in the config
use DummyModelNamespace; //is the model such as App\Models\User
use Prettus\Repository\Eloquent\BaseRepository;
//is the `model_name`.`postfix` such as `UserController`
class DummyClass extends BaseRepository
{
/**
* @return string
*/
public function model()
{
//`DummyModelUcfirst` is mean to the model_name ,such as `User`
return DummyModelUcfirst::class;
}
}
Please see the changelog for more information on what has changed recently.
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
MIT. Please see the license file for more information.