Laravel Template is a project template for all Codebar Solutions AG Laravel applications. It is a starting point for new Laravel projects. It includes a basic setup for a Laravel application with some common packages and configurations.:
- Auth
- Support for Microsoft Office 365 Authentication
- Enums
- Laravel Nova.
- Flysystem Cloudinary.
- Flysystem Cloudinary Nova.
- Spatie Activity Log.
- Spatie Health.
- Spatie Permission.
You can use this template by clicking on the Use this template button on the top of this github repository page.
*INSERT IMAGE HERE *
Once you have created a new repository from this template, you can clone it to your local machine and install the dependencies:
composer install
cp .env.example .env
cp vite.config-example.js vite.config.js
php artisan key:generate
php artisan migrate --seed
npm install
npm run buildIf you want to use Valet to serve your application, you can run the following command:
valet link
valet secure
valet openIf you want to user Herd to serve your application, you can run the following command:
herd link
herd secure
herd openYou can run the development asset server with the following command:
npm run devNote: You should set
valetTls: 'your-domain.test',belowrefresh: true,in yourvite.config.jsfile if you usevalet secureorherd secure.
Assets should be set in the following directories:
resources/jsfor JavaScript files.resources/cssfor CSS files.resources/fontsfor Font files.resources/imagesfor Image files.
After you have added your assets, you can run the following command to compile them:
npm run buildTo include your assets in your blade files, you can use the following:
{{ Vite::asset('resources/images/your-image.png') }}Auth is enabled by default.
You can configure auth settings in the config/laravel-auth.php file.
If you wish to use email verification, you can use the following middleware to protect your routes:
Route::middleware(['laravel-auth-middleware'])->group(function () {
...
});To use verification in nova, add the middleware into in your nova.php config:
/*
|--------------------------------------------------------------------------
| Nova Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be assigned to every Nova route, giving you the
| chance to add your own middleware to this stack or override any of
| the existing middleware. Or, you can just stick with this stack.
|
*/
'middleware' => [
'web',
'laravel-auth-middleware',
HandleInertiaRequests::class,
DispatchServingNovaEvent::class,
BootTools::class,
],MICROSOFT_REDIRECT_URI environment variable. You can use expose or ngrok for local development.
APP_URL=https://your-expose-or-ngrok-url.com
# ✅ This is recommended for production as well:
MICROSOFT_REDIRECT_URI="${APP_URL}/auth/service/microsoft/redirect"Please refer to the Spatie Permission documentation for more information on how to use permissions.
Enums are included in PHP's core functionality but we have some additional functionality to make them easier to use.
You can create an enum in the app/Enums directory:
<?php
namespace App\Enums;
use App\Interfaces\LabelEnumInterface;use App\Traits\HasLabels;
enum EnvironmentEnum: string implements LabelEnumInterface
{
use HasLabels;
case PRODUCTION = 'production';
case STAGING = 'staging';
case LOCAL = 'local';
public function label(): string
{
return match ($this) {
EnvironmentEnum::PRODUCTION => __('Production'),
EnvironmentEnum::STAGING => __('Staging'),
EnvironmentEnum::LOCAL => __('Local'),
};
}
}You should use the HasLabels trait to add a label method to your enum.
You should also implement the LabelEnumInterface interface to ensure that the label method is implemented.
The label method should return the label for the enum value.
You can use the enum in your code like this:
// Native PHP Enum
$enum = EnvironmentEnum::PRODUCTION; // Enum Object
$name = EnvironmentEnum::PRODUCTION->name; // Enum Name (PRODUCTION)
$value = EnvironmentEnum::PRODUCTION->value; // Enum Value (production)
// Label
$label = EnvironmentEnum::PRODUCTION->label(); // Enum Label using Laravels Translation (Production)
// Labels
$labels = EnvironmentEnum::labels(); // Array of Enum Labels with Enum value as Key (['production' => 'Production', 'staging' => 'Staging', 'local' => 'Local'])Please refer to the Spatie Health documentation for more information on how to use health checks.
We have added two health checks which are located in the app/Checks directory:
FailedJobsCheckJobsCheck
We have added some helper functions which are located in the app/Helpers directory
You should the Facades for the helpers which are located in the app/Helpers/Facades directory:
HelperBankHelperDateHelperDeviceHelperFileHelperMarkdownHelperMoneyHelperNumberHelperPhone
We have added feature policy which is located in the app/FeaturePolicy directory.
It is enabled by default and you can configure it in the config/feature-policy.php and config/default.php file.
The Feature Policy Middleware is installed and enabled by default in the bootstrap/app.php file.
We have added some traits which are located in the app/Traits directory.
HassUuid
We also have some traits which are located in the app/Traits/Nova directory which are intended for use only in Laravel Nova.
NovaCustomOrderTraitNovaIdentificationPanelTraitNovaLanguageTraitNovaTimestampsPanelTrait
We have added some blade components which are located in the resources/views/components directory.
fathom.blade.phpfavicons.blade.php
You should include both the blade components in your blade layout files
Please refer to the respective documentation for the Cloudinary and Cloudinary Nova packages.
We use Filament for notifications. Please refer to the Filament documentation for more information on how to use notifications.
We use Laravel Pint to format code.
You can run the following command to format your code:
./vendor/bin/pintYou can run the following command to format your blade files:
./vendor/bin/pint --bladeThe blade formatter is still in beta and may not work as expected. if you wish to not use this update your
composer.jsonto use the latest version oflaravel/pintinstead of the dev branch.
We use PestPHP for testing.
You can run the following command to run your tests:
./vendor/bin/pestPlease refer to the PestPHP documentation for more information on how to use PestPHP.
The Laravel framework is open-sourced software licensed under the MIT license.