This package should help you with creating and managing a Laravel DDD Application

Overview

Laravel Beyond

This package should help you with creating and managing a Laravel DDD Application. This package is heavily inspired by "Laravel beyond CRUD" from Spatie.

Installation

Install laravel-beyond with composer

composer require --dev regnerisch/laravel-beyond

Usage

You can easily set up a DDD application with php artisan beyond:setup after installation. You should only run this command on a freshly installed Laravel app, as it will delete files and rename things. After the setup has finished you need to run composer dump-autoload.

You can 'make' Controllers, Commands, Models as you know it from Laravels' php artisan make:... with the beyond:make:... command. For application commands e.g. php artisan beyond:make:controller you need to enter the following schema: {App}/{Module}/{Class}:

php artisan beyond:make:controller Admin/Users/UserController

For domain commands e.g. php artisan beyond:make:action you need to enter the following schema: {Domain}/{Class}:

php artisan beyond:make:action Users/CreateUserAction

Making commands (with php artisan beyond:make:command) will automatically force them to the Command application, so you only need to enter the command name: php artisan beyond:make:command SyncUsersCommand.

Commands

php artisan beyond:make:action Users/CreateUserAction
php artisan beyond:make:collection Users/UserCollection
php artisan beyond:make:command UpdateUsersCommand
php artisan beyond:make:controller Admin/Users/UserController
php artisan beyond:make:dto Users/UserData # required spatie/data-transfer-object
php artisan beyond:make:job Admin/Users/SyncUsersJob
php artisan beyond:make:model Users/User
php artisan beyond:make:policy Users/UserPolicy
php artisan beyond:make:query-builder Users/UserQueryBuilder
php artisan beyond:make:query Admin/Users/UserIndexQuery # requires spatie/laravel-query-builder
php artisan beyond:make:request Admin/Users/CreateUserRequest
php artisan beyond:make:resource Admin/Users/UserResource
php artisan beyond:make:route Users
php artisan beyond:setup

Roadmap

  • tbc.

Authors

License

ISC

Comments
  • Remove old method fromRequest() from DTO stub

    Remove old method fromRequest() from DTO stub

    From v3 of Spatie DTO package seem that fromRequest() it's not anymore the way to be used.

    I checked readme of v2 and I found it, but in v3 it's not anymore there.

    opened by thewebartisan7 13
  • add trait command

    add trait command

    As https://github.com/regnerisch/laravel-beyond/issues/54 requested, I have created beyond:make:trait command.

    The trait is created in Domain\XXX\Traits namespace by default. You can add --support flag to create the trait in Support\Packages\Laravel\Traits namespace.

    opened by dimzeta 6
  • DTO Factory flag

    DTO Factory flag

    As discussed here https://github.com/regnerisch/laravel-beyond/pull/58 this PR add a new optional flag --factory in DTO command. When added will be create a new class in App for DTO Factory.

    Usage:

    # Will ask Domain, Class name and App
    beyond:make:dto --factory
    
    # Will ask App and create the factory in 
    # `src/App/Web/User/DataFactories/UserDataFactory.php` (Supposely App provided is "Web")
    beyond:make:dto User/UserData --factory
    

    A DTO like this:

    <?php
    
    namespace Domain\Users\DataTransferObjects;
    
    use Spatie\DataTransferObject\DataTransferObject;
    
    class MyData extends DataTransferObject
    {
        // Add properties here
    }
    

    Will create a DTO Factory:

    <?php
    
    namespace App\Admin\Users\DataFactories;
    
    use Illuminate\Http\Request;
    
    use Domain\Users\DataTransferObjects\MyData;
    
    class MyDataFactory
    {
        public static function fromRequest(Request $request): MyData
        {
            return new MyData($request->all());
        }
    }
    
    opened by thewebartisan7 5
  • [3.x] Alternative way to execute commands

    [3.x] Alternative way to execute commands

    Currently commands are restricted to beyond:make:command {schema}. We should provide an alternative way since not everybody is used to "Laravel Beyond CRUD" and may not know the schema.

    • php artisan beyond:make:model should ask for Domain and Class Name and creates a class based on these information
    enhancement 
    opened by alexgaal 5
  • Setup needs manual adding of code

    Setup needs manual adding of code

    Hello,

    when setting up the project I get the prompt to add something to the boot method of my AppServiceProvider.

    1. Which exact namespace is this Factory? There are multiple ones provided by Laravel.
    2. Why is this not automatically added?

    image

    opened by Wulfheart 4
  • Extend the default base controller of Laravel

    Extend the default base controller of Laravel

    Instead of adding for each controller the default Laravel traits for controller, would be better to keep the default Laravel controller as Base controller and then extend it.

    So the controller.stub would be:

    <?php
    
    namespace App\{{ namespace }}\Controllers;
    
    use Support\Packages\Laravel\Controllers\Controller;
    
    class {{ className }} extends Controller
    {
        // Methods here...
    }
    

    And we can add the base controller for example inside Support/Packages/Laravel/Controller with default content:

    <?php
    
    namespace Support\Packages\Laravel\Controllers;
    
    use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
    use Illuminate\Foundation\Bus\DispatchesJobs;
    use Illuminate\Foundation\Validation\ValidatesRequests;
    use Illuminate\Routing\Controller as BaseController;
    
    class Controller extends BaseController
    {
        use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
    }
    
    opened by thewebartisan7 4
  • Laravel action queueable package

    Laravel action queueable package

    Would you be interested in adding this package for action:

    https://github.com/spatie/laravel-queueable-action

    As replacement for current MakeActionCommand, or as a new one.

    Command signature would be:

    beyond:make:qa {name?} {--overwrite} {--queueable}

    or in case as replacement for current Action:

    beyond:make:action {name?} {--overwrite} {--queueable}

    I am tempted also by this package https://laravelactions.com/ but maybe it's too much, even if can be cherry pick what you want from it, https://laravelactions.com/2.x/granular-traits.html#cherry-picking

    Also not sure how if this can be even combined with DDD.

    What you think?

    opened by thewebartisan7 4
  • More info regarding Support/Packages/Laravel

    More info regarding Support/Packages/Laravel

    I read only the free blog of laravel beyond, so maybe this is explained in the paid book.

    I see that we can use flag --support for middleware and rule, and this add them inside Support/Packages/Laravel.

    For example if I create a middleware with --support this is created in:

    Support/Packages/Laravel/Middleware

    Why inside "Laravel" folder and not in Support/Middleware?

    Also there is already a folder Support/Packages/Laravel/Middlewares (with final "s"), while our middleware is created inside Support/Packages/Laravel/Middleware (without "s").

    As I can read about Support namespace in the blog article "as the dumping ground for all little helpers that don't belong anywhere". So not sure why everything it's under "Support/Packages/Laravel" and not directly inside "Support/Middleware", etc..

    Not sure if for questions like this there is another place.

    Thanks

    opened by thewebartisan7 4
  • Support for Builders

    Support for Builders

    Laravel Beyond Crud has the concept of Builders. They aren’t yet implemented I think as the query command of this package is for another things, isn’t it?

    opened by Wulfheart 4
  • Commands are not automatically registered

    Commands are not automatically registered

    Hi, thank you for this package, this is what I wanted for so long!

    I created a new Command: php artisan beyond:make:command CreateUserTokenCommand

    This command does not appear automatically when I do php artisan list.

    Maybe i'm wrong but after some research, it seems because load($paths) into Illuminate\Foundation\Console\Kernel tries to remove a part of the file path with app_path():

    $command = $namespace.str_replace(
        ['/', '.php'],
        ['\\', ''],
        Str::after($command->getRealPath(), realpath(app_path()).DIRECTORY_SEPARATOR)
    );
    

    But it doesn't work, because app_path returns /Users/dimzeta/Sites/laravel/app while the real app path should be /Users/dimzeta/Sites/laravel/src (Is it correct ?)

    EDIT:

    As soon as I use base_path('src/App') instead of app_path() it's working well. But maybe this is not the right way, because we still have a wrong path using app_path() ?

    bug 
    opened by dimzeta 3
  • Update README.md

    Update README.md

    Hi, Currently, there is an error when we copy and paste the given code block to AppServiceProvider. This will fix the following errors:

    1. syntax error, unexpected identifier "Factory", expecting ";" at src/App/Providers/AppServiceProvider.php:27
    2. Class "App\Providers\Illuminate\Database\Eloquent\Factories\Factory" not found at src/App/Providers/AppServiceProvider.php:26 Thanks
    opened by krishnahimself 2
  • Deptrac integration

    Deptrac integration

    Just like #37 based on Ryutu Hamasakis talk at Laracon Online Winter 2022 (https://youtu.be/0Rq-yHAwYjQ?t=5885 -> link now with different timestamp than before): To seperate the domain boundaries we could use deptrac and maybe add this to the default template. What do you think?

    enhancement 
    opened by Wulfheart 4
Releases(v5.3.1)
Owner
J. Regner
PHP-Developer
J. Regner
This template should help get you started developing with laravel 9 + Vue 3 in Vite + Tailwind

simple-project This template should help get you started developing with laravel 9 + Vue 3 in Vite + Tailwind

Yemeni Open Source 4 Oct 5, 2022
laravel package help you to implement geographical calculation, with several algorithms that help you deal with coordinates and distances.

Geographical Calculator Geographical Calculator was developed for laravel 5.8+ to help you to implement geographical calculation, with With several al

karam mustafa 342 Dec 31, 2022
Cache-purge-helper - Additional instances where nginx-helper and lscache plugin should be purged.

cache-purge-helper Additional instances where nginx-helper and lscache plugin should be purged. Install Extract the zip file. Upload them to /wp-conte

Jordan 10 Oct 5, 2022
Electrik is a full-featured, open-source, starter-kit to help you build you your SaaS application.

Electrik Electrik is a full-featured and open-source stater-kit for for your next SaaS application. It's built on top of Laravel, Livewire, neerajsoha

Electrik 129 Dec 31, 2022
Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be.

VatCalculator Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be. Integrates with Laravel and Cashier — or in a st

Dries Vints 1.1k Jan 5, 2023
Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be.

VatCalculator Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be. Integrates with Laravel and Cashier — or in a st

Dries Vints 1.1k Jan 7, 2023
Create and manage A Domain Driven Design (DDD) in your Laravel app, simply and efficiently.

Create and manage A Domain Driven Design (DDD) in your Laravel app, simply and efficiently.

Lucas Nepomuceno 4 Jun 11, 2022
Testbench Component is the de-facto package that has been designed to help you write tests for your Laravel package

Laravel Testing Helper for Packages Development Testbench Component is the de-facto package that has been designed to help you write tests for your La

Orchestra Platform 1.9k Dec 29, 2022
You already have your dream house? Sam Building will help you find the perfect home.

SAM BUILDING Setup Fork or clone this repo! git clone github.com/Igorballo/Real-Estate-App.git Installation des dépendances npm install #or yarn insta

null 4 Nov 29, 2022
This package aims to help you standardize all your API responses in a simple and structured way.

Laravel API Response This package aims to help you standardize all your API responses in a simple and structured way. By default, the stucture of the

Kode Pandai 6 Dec 6, 2022
this package can help you to test race condition in Laravel Feature Test

Laravel Async Testing this package can help you to test race condition in Laravel Feature Test Requirements Laravel versions 5.7, 6.x, 7.x and 8.x PHP

Recca Tsai 61 Nov 5, 2022
a Laravel package help you to execute more effective databases queries.

Laravel Query Helper Laravel Query Helper was developed for laravel 7.2+ to help you optimizing sql queries, this package will contain all advanced sq

karam mustafa 9 Jul 26, 2022
Relational Metrics - lararvel package help you to make your metrics easier

Relational Metrics This package will help you to make your metrics easier, You could get metrics about your Models, Models depending on their relation

Syrian Open Source 25 Oct 12, 2022
A Laravel chat package. You can use this package to create a chat/messaging Laravel application.

Chat Create a Chat application for your multiple Models Table of Contents Click to expand Introduction Installation Usage Adding the ability to partic

Tinashe Musonza 931 Dec 24, 2022
Laravel Query Helper was developed for laravel 7.2+ to help you optimize sql queries

Laravel Query Helper Laravel Query Helper was developed for laravel 7.2+ to help you optimize sql queries, this package will contain all advanced SQL

Syrian Open Source 15 Nov 20, 2022
Learning Websocket by creating Custom Websocket-server package provided by Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling.

Chisty Md.Muzammel Hossain 3 Oct 25, 2022
Laravel package for creating Word documents with Eloquent ORM dependencies.

Laravel Eloquent Word This package provides an elegant way to generate Word documents with Eloquent Models. Uses PHPOffice/PHPWord package to generate

Marvin Quezon 6 Aug 5, 2022
A Laravel package for creating a Markdown driven blog in minutes.

Static Markdown Blog A Laravel package for generating static blog posts from Markdown files. Sometimes, you want a blog but don't necessarily want to

Danny 0 Nov 12, 2022
The api help to manage wso2 users from laravel application

Laravel WSO2 Identity API User This is a Laravel library to manage WSO2 IDP users. Installation You can install the package via composer: composer req

Kalyan Halder Raaz 2 Dec 12, 2021