Skip to content

wayofdev/laravel-starter-tpl

Repository files navigation





Laravel Starter Template

This is an opinionated modified version of the Laravel framework which aims at providing a Domain-Driven Design (DDD) structure.

📄 About

Laravel is a popular PHP web framework that provides an easy and efficient way to build web applications. However, the default structure of Laravel, coupled with Eloquent's active record pattern, may not always fit the needs of a project that requires a Domain-Driven Design (DDD) architecture. Eloquent's active record pattern breaks DDD principles and make it difficult to separate your business logic from your infrastructure code.

This repository provides a modified file structure for Laravel that follows DDD principles and tries to adhere to best practices, such as those outlined in Spatie's Laravel Beyond CRUD. The goal is to provide a starting point for building Laravel applications using a DDD approach, while still leveraging the power and convenience of the Laravel framework.


🙏 If you find this repository useful, consider giving it a ⭐️. Thank you!


🚀 Features

This starter template includes several added, changed, and removed features:

  • Added:
    • Strict types declaration in all PHP files
    • Style checker package for custom rule-sets to php-cs-fixer — wayofdev/php-cs-fixer-config
    • Static analysis tool — PHPStan and it's extensions:
    • Pest testing framework
    • Github action workflows for:
      • Continuous integration which includes coding standards checks, unit testing and static analysis
      • Automatic pull-request labeling
      • Deployer for automatic deployments to staging and production servers with support of Github Environments
    • ergebnis/composer-normalize composer plugin for normalizing composer.json file
    • roave/securityadvisories package to ensure that application doesn't have installed dependencies with known security vulnerabilities.
    • Application dockerization using docker-compose and Makefile — use make help to view available commands
    • Git pre-commit hooks using pre-commit package
  • Changed:
    • Marked default Laravel classes as final
    • Modified file structure to meet DDD principles
    • Changed config folder files to use default PHP multi-line comment style
  • Removed:
    • Dependencies like Laravel Sanctum, Laravel Pint, and Laravel Sail.
    • Broadcasting service provider and it's routes. It can be added back, if it will be required for project
    • Console routes in favor of Command classes.
    • Sanctum migration files

🚩 Requirements

To use this repository, you need to meet the following requirements:


💿 Installation

Warning: You should configure, set up, and run the docker-shared-services repository to ensure system-wide TLS and DNS support.

  1. Clone repository:

    After forking or creating generating repository from template, you can clone it to your local machine. In this example we will use laravel-starter-tpl repository as starting point.

    $ git clone git@github.com:wayofdev/laravel-starter-tpl.git
  2. Generate .env file

    Generate .env file from .env.example file using Makefile command:

    $ make env \
        APP_NAME=laravel \
        SHARED_SERVICES_NAMESPACE=ss \
        PROJECT_SERVICES_NAMESPACE=wod \
        COMPOSE_PROJECT_NAME=laravel-starter-tpl

    Change generated .env file to match your needs, if needed.

    (Optional): to re-generate .env file, add FORCE=true to the end of command:

    $ make env \
        APP_NAME=laravel \
        SHARED_SERVICES_NAMESPACE=ss \
        PROJECT_SERVICES_NAMESPACE=wod \
        COMPOSE_PROJECT_NAME=laravel-starter-tpl \
        FORCE=true
  3. Build, install and run. This will also generate Laravel app key:

    $ make
    
    # or run commands separately
    $ make hooks
    $ make install
    $ make key
    $ make prepare
    $ make up

🤝 License

Licence


🧱 Credits and Useful Resources

Useful resources about Laravel and DDD approach:


🙆🏼‍♂️ Author Information

This repository was created in 2022 by lotyp / wayofdev.


🙌 Want to Contribute?

Thank you for considering contributing to the wayofdev community! We are open to all kinds of contributions. If you want to:

  • 🤔 Suggest a feature
  • 🐛 Report an issue
  • 📖 Improve documentation
  • 👨‍💻 Contribute to the code