Search code examples
phplaravel-5laravel-artisan

How to effectively create controller or model without using php artisan?


Why must i use php artisan to create controller or model in laravel. Can i not just use the IDE to create a blank controller or model class?


Solution

  • Sure you could just make your Controllers and Models by hand, but its pretty convenient to use php artisan.

    Pretty much all IDE's have support for snippets. You could make snippets for controllers and models.

    Controller example snippet

    <?php
    namespace App\Http\Controllers;
    use Illuminate\Http\Request;
    
    class YourController extends Controller
    {
        public function index(Request $request)
        {
    
        }
    
    }
    

    Model example snippet

    <?php
    class ModelExample extends Model
    {
        protected $table = 'model_table';
    
    
    }
    

    I prefer and highly recommend using php artisan instead of using your IDE's snippets-feature.