Skip to content

Getting Started

Welcome to Modular! This guide will walk you through the process of installing Modular on a fresh Laravel 11 installation, and setting up your project to start building your application.

Video Tutorial

We have prepared a 2-minute video tutorial to guide you through the installation of Modular on a fresh Laravel 11 installation:

Step 1 - Configure your database and run the migrations

We'll begin by assuming that you have a fresh Laravel 11 installation that is up and running. Firstly, configure the database connection in your .env file (located at the root of your Laravel project). You must be able to run the php artisan migrate command without errors to continue the setup:

bash
php artisan migrate

If you are using Laravel Sail, use the following command instead:

bash
sail artisan migrate

Step 2 - Require the Modular package

Open your terminal and navigate to your project's root directory. Then, run the following command to install the Modular package:

bash
composer require daniel-cintra/modular

If you are using Laravel Sail, use the following command instead:

bash
sail composer require daniel-cintra/modular

This will install the Modular package in your Laravel project and enable the auto-installation of the required dependencies.

Step 3 - Run the Modular installer

Now, run the modular:install command to complete the setup process:

bash
php artisan modular:install

If you are using Laravel Sail, use the following command instead:

bash
sail artisan modular:install

If asked, confirm that you want the installer to create the database for you.

The modular:install command will:

  1. Install the required composer dependencies and publish the vendor package's configuration files.

  2. Install the required npm dependencies and configure frontend tooling like Tailwind CSS and Vite.

After a successful installation, open your browser and access your APP_URL (as configured in your .env file). You should see the Modular index page, as shown below:

Modular Login Page

Publish the Modular configuration file (Optional)

Optionally, you can publish the Modular configuration file to customize the default settings of the package. This command will publish the configuration file to the config/modular.php directory of your project:

bash
php artisan vendor:publish --tag=modular-config

The Modular configuration file contains the following settings:

php
<?php

return [
    // URL of the login page
    'login-url' => '/',

    // Default route to redirect the user after login
    'default-logged-route' => 'dashboard.index',
];

Publish Language Files (Optional)

Optionally, you can publish the language files of the Modular package to customize the default messages and translations used in Authentication, Dashboard Menu, etc. This command will publish the language files to the lang/vendor/modular directory of your project:

bash
php artisan vendor:publish --tag=modular-translations

Bonus: Publish Laravel Language Files (Optional)

You can also publish the language files of Laravel for validation messages, reset passwords, authentication, and pagination. Currently, this feature is only available for pt_BR (Brazilian Portuguese):

bash
php artisan modular:publish-laravel-translations --lang=pt_BR

The command above will create a new language directory inside the lang directory of your project, named after the language you have chosen (in this example "pt_BR").

For translating the Laravel language files to other languages, you can follow the Laravel Docs on Localization.