Download the PHP package lazerg/laravel-modular without Composer

On this page you can find all versions of the php package lazerg/laravel-modular. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-modular

Version Downloads count Repository count Last commit Stars count

Dividing a Laravel project into modules enhances code organisation by isolating features and functionalities into separate, manageable units. This modular approach improves scalability by allowing each module to be developed, tested, and maintained independently, which speeds up development and reduces the risk of conflicts.

It also promotes reusability, as modules can be easily reused in other projects, fostering a more efficient development process and reducing duplication of effort.

Installation

Create a new module

When we start a new project, we need to move current files to modules. Let's create modules/User/app directory. And register it in composer.json file.

Do not forget to composer dump-autoload after changes.

After registering module, create UserServiceProvider in modules/User/app directory. It must extend ModuleServiceProvider. Next you need to register this service provider in bootstrap/providers.php file.

Move default files to module

  1. Move /app/Modules/User to /modules/User/app/Modes/User
  2. Change auth.providers.users.model config to Modules\User\Models\User.
  3. Move /database/migrations/2014_10_12_000000_create_users_table.php to /modules/User/database/migrations/2014_10_12_000000_create_users_table.php
  4. Move /database/factories/UserFactory.php to /modules/User/database/factories/UserFactory.php

Setup seeder

  1. database/seeders/DatabaseSeeder.php must extend ModularDatabaseSeeder. And do not override run method.
  2. Create DatabaseSeeder in modules/User/database/seeders directory. It must extend BaseDatabaseSeeder
  3. Create UserSeeder in modules/User/database/seeders directory. It must extends Illuminate\Database\Seeder
  4. Register UserSeeder in DatabaseSeeder's $earlySeeders or $seeders property.

Loaders

Inside ModuleServiceProvider we have different loaders:

Path Register & Usage
modules/{module}/app/Commands $commands property in ServiceProvider
modules/{module}/app/Events $events property in ServiceProvider
modules/{module}/app/Observers $observers property in ServiceProvider
modules/{module}/app/Policies $policies property in ServiceProvider
modules/{module}/config all files from modules/{module}/config folder will be registered. Can be accessed like: config(’User::settings.max_attempt’)
modules/{module}/database/migrations all files from modules/{module}/database/migrations folder will be registered
modules/{module}/routes web.php, api.php and console.php will be registered
modules/{module}/lang Can be accessed like: trans(’User::details.full_name’)
modules/{module}/views Can be accessed like: view('User::about.details')
modules/{module}/database/seeders/DatabaseSeeder It must extend BaseDatabaseSeeder. Other seeders must be registered in its $earlySeeders or $seeders property

Routes

web.php

option default modification
name users.index to make it user.index set $disableRoutePluralization = true in UserServiceProvider
namespace Modules\User\Http\Controllers
middleware [’web’, ‘auth’] to remove auth set $mustBeAuthenticated = false in UserServiceSeeder . To make all routes for guest, set $mustBeGuest = true
url /users/index to make it /user/index set $disableRoutePluralization = true in UserServiceProvider. To make it just /index set $disableWebRoutePrefix = true

api.php

option default modification
name api.users.index to make it api.user.index set $disableRoutePluralization = true in UserServiceProvider
namespace Modules\User\Http\Api\Controllers
middleware [’api’, ‘auth’] to remove auth set $mustBeAuthenticated = false in UserServiceSeeder. To make all routes for guest, set $mustBeGuest = true
url /api/users/index to make it /api/user/index set $disableRoutePluralization = true in UserServiceProvider.

All versions of laravel-modular with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
laravel/framework Version ^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lazerg/laravel-modular contains the following files

Loading the files please wait ....