Skip to content

Package Development

Tuhin Bepari edited this page Jul 30, 2018 · 3 revisions

One of the best way to write reusable and components based code in Laravel is Package. To Do that run following

Step One: Create Package

   php artisan laracrud:package Blog

It will generate a folder inside packages folder. However you can set your custom path from package configuration in laracrud.php

Step Two: Register package into Composer Autoload. See example below

      "psr-4": {
            "App\\": "app/",
            "Blog\\": "packages/blog/src/",
            "Photo\\": "packages/photo/src/"
        }

Step Three: Change config file

    //file: config/laracrud.php

    'rootNamespace' => 'Blog',
    'route' => [
        'web' => 'packages/blog/routes/web.php',
        'api' => 'packages/blog/routes/version1.php',
        'prefix' => 'blog::'
     ],
     'view' => [
          'path' => base_path('packages/blog/resources/views'),
          'namespace' => 'blog',
     ]     

Congrats everything is setup successfully. Anything you create it will be saved on your package folder.

Video Tutorial

Are you a visual learner then watch video tutorial

You can’t perform that action at this time.