Laravel Custom Stub

 This is how i customized the stubs in laravel for the easy development. i was feeling lazt to write the same template every time so below is the process to customize your stubs as you like .

php artisan stub:publish

Generates the stubs folder with the list of  file in you root directory


here i created controller.custom.stub file in the stubs folder and customized the stub

<?php


namespace {{ namespace }};


use Illuminate\Http\Request;

use App\Http\Controllers\System\ResourceController;


class {{ class }} extends ResourceController

{

    public function __construct(ServiceName $variableService)

    {

        parent::__construct($variableService);

    }

    public function moduleName()

    {

        //return 'courses';

        return 'moduleName';

    }

    public function viewFolder()

    {

        // return 'system.course';

        return 'viewFolder';

    }

  }

To excute the stub

php artisan make:controller --type=custom MyController


Comments