Laraship

⌘K
  1. Home
  2. Docs
  3. Laraship
  4. Customize Laraship
  5. Module Structure

Module Structure

Laraship is a Modular platform, which means functionalities are categorized in modules, each module has its own folder, the same thing for themes. there can be slight changes among module structures depends on the functionalities available, there are 3 types of modules in Laraship.

  • Core Modules: they are the must-have modules to get Laraship up and running, they are enabled by default and cannot be disabled.
  • Plugins: Extra functionalities provides to different platforms like eCommerce, Subscription, Classified.
  • Payments: Payment gateway to process different types of payments whether it’s one-time payments or recurring payments.

 

Module File Structure:

for any Laravel Developer: Laraship module structure is very similar to Laravel modules, Laraship team tried to keep names and conventions very close to Laravel so any Laravel developer will be able to recognize the structure easily, below is a sample module which is the entity module structure. let’s review these folders

 

 

    1. module.json :  is a module identifier that describes module details like name, version, base folder name, compatible platforms, dependencies, for example
      {
        "code": "corals-utility",
        "name": "Utility Module",
        "author": "Corals",
        "type": "module",
        "description": "Utility Package",
        "namespace": "Corals\\Modules\\Utility\\",
        "provider": "UtilityServiceProvider",
        "version": "4.0",
        "load_order": "0",
        "folder": "Utility",
        "autoload": "psr-4",
        "icon": "fa fa-cloud",
        "require": {
        }
      }
      
    2.  Composer.json specifies laravel dependencies and requests to be installed when installing this plugin,
      they are installed using the composer tool.
    3. ModuleServiceProvider: this is the initializer of the module which defines what are the routes, language folders, aliases, .., for more details about service providers please refer to Laravel documentation.
    4. Providers: under this folder are the initializers used on module actions like install, uninstall, activate. deactivate for example you can instruct to seed some data, copy folders…,
    5. Classes: standard laravel and PHP classes
    6. Commands: if you have console commands to be executed using laravel artisan, for more info about the laravel artisan command check the below laravel document.
    7. config: Laravel standard config files where you define the configuration and assign them to the module scope, for more info about laravel configuration setup check this Link
    8. database: contains database schema creation and data to be seeded,  for more info please refer to laravel manual.
    9. DataTables: Laraship powers Yajara Laravel DataTables with Service implementation for Tables Listing, within these Datatables classes you define which columns to show in addition to many customizations explained here
    10. Facades: Laravel facades serve as “static proxies” to underlying classes in the service container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods. It’s perfectly fine if you don’t totally understand how facades work under the hood – just go with the flow and continue learning about Laravel. for more details, please refer to laravel documentation.
    11. Http:  this folder contains both Requests and Controllers, controllers basically received the request routes and do the needed functionality like display a view, return a json file, call an API ., Laravel Requests are mainly used to validate requests before they are processing by controllers, for example validate all data is there with the right format and constrains, Laravel controllers document can be found here and for Laravel Requests here.
    12. Mail: Classes that extend Laravel mailable feature to build the emails using Laravel Notification templates and input passed to the template using the views located under views/emails
    13. Middleware: Middleware provides a convenient mechanism for inspecting and filtering HTTP requests entering your application. For example, Laravel includes a middleware that verifies the user of your application is authenticated. If the user is not authenticated, the middleware will redirect the user to your application’s login screen. However, if the user is authenticated, the middleware will allow the request to proceed further into the application.
    14. Models: Models are the representation of database tables and they are used to query, insert, update your table, they are also commonly referenced as eloquent in Laravel.
    15. Notifications: Classes that connect Laraship Notification templates with the Laravel Mailer system, define available parameters and how variables are being replaced inside the template body, and who are the recipients.
    16. Observers: Laravel Model Observers is a great feature. Observers are used to group event listeners for a model. Observers classes method names refer to the Eloquent event you want to listen for. These methods receive the model as their only argument. Laravel does not include a default directory for observers. Also, the artisan command for generating observers is also not available by default. for more tutorials, you can refer to this URL
    17. Policies: Policies are classes that organize authorization logic around a particular model or resource, Once the policy class has been created, it needs to be registered. Registering policies is how we can inform Laravel which policy to use when authorizing actions against a given model type. this is a standard Larevel authorization module
    18. public: this folder contains public assets like js and CSS files that need to be copied to the public folder on install or update.
    19. resources: contains views blades and language files https://laravel.com/docs/8.x/blade
    20. routes: API and Web routes configuration for the module: https://laravel.com/docs/8.x/routing
    21. Services: Centralized location for common controller functions to be shared between API and Web controllers and avoid code duplication.
    22. Traits: common functions that can be injected into Models to provide common functionalities general, Traits are nothing but a reusable collection of methods and functions that can be incorporated in any other classes. Let’s see the exact memoir of Traits as per PHP:https://www.positronx.io/laravel-traits-example/ 
    23. Transformers: Contains Presenters and Transformer Classes, they are used to do some processing on raw data before presenting it to the frontend, for example, make it hyperlinked, add labels. colors. , or any kind of data manipulation.
    24. update-batches: PHP scripts that are called to  perform updates to the module to get the latest version, for example adding new columns, mass updates on data, replace files …