jefhar/laravel-domain-oriented

This package is abandoned and no longer maintained. No replacement package was suggested.

The Laravel Framework.

Installs: 5

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 21 260

Type:project


README

68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6474666276766b79702f696d6167652f75706c6f61642f76313536363333313337372f6c61726176656c2d6c6f676f6c6f636b75702d636d796b2d7265642e737667

Build Status Total Downloads Latest Stable Version License

About 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. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

Laravel is accessible, powerful, and provides tools required for large, robust applications.

About Domain Oriented Laravel

First things first, I didn't come up with this re-design of the Laravel Framework. This builds upon the very fine blog posts by Brent. The steps from the first chapter of Brent's blog have already been performed.

Keep your application layer in app/App directories. This is where you will find the Console, Exceptions, Http, and Providers directories. They work the same as the default Laravel application, they're just moved down one directory, but still in the \App namespace.

Place your Domain logic organized by domain concern within the app/Domain directory in the \Domain namespace. Support logic should be in the app/Support directory within the \Support namespace.

Caveats

Any php artisan make commands will place the newly created file where stock Laravel expects it to, not where Domain Oriented Laravel expects it to be. If you need artisan to create the file, you will need to manually move it to the correct directory. The default location is acceptable for database and test files.

Additional Changes

Docker

This comes with an opinionated docker stack for unit testing and deployment. Prepackaged with redis, mysql:8.0, nginx, php:7.4 and mailhog, this stack is easily customizable to suit your needs. Simply add or change a stanza within the docker-compose file. The Makefile contains commands to alias common docker-compose exec commands.

User Permissions

I have added the spatie/data-transfer-object and spatie/laravel-permission packages to the composer environment. After migrating and seeding, you will have three sample users ; a superAdmin, an employee, and a subscriber, all with password password and email address of <username>@example.com.

The users all have sample roles and permissions which are defined as class constants in the UserRoles and UserPermissions classes.

Modify/remove the migration and seeder files as needed. You can also add variables to your .env file if you want to change the passwords, emails, or usernames.

** Note that the laravel/ui composer package has not been included.

Composer

I added nunomaduro/larastan, sensiolabs/security-checker, and squizlabs/php_codesniffer to the development environment. Unless you rely soley on your IDE to tell you that you have possibly

The command composer phpcs will check your app/ and tests/ directories to make sure all files are in accordance with PSR-12.

composer phpcbf will correct any files that it can in those directories to make sure they follow PSR-12.

Running composer pretest will first check your composer.lock file to search for any advisories in the Security Advisories Database. If no security advisories for your packages exist, it will make sure that larastan approves of your code. If all is still good, your code will be examined to make sure it is in compliance with PSR-12 standards.

composer test will run your unit and feature tests.

Gitlab CI

Domain Oriented Laravel distribution also comes with a CI pipeline for GitLab. By default, it will install the composer and npm dependencies and create a cache, based upon your gitlab repository and branch. It will then, in parallel, run your unit and feature tests, and dusk tests.

If you have installed gitlab-runner locally, either through brew or a GitLab source, make ci will run your latest git commit through the unit and feature tests.

When you push a tagged commit to GitLab, the deployment stage will run. Before you do that, create an Envoy.php file. Also create a deployment user on your server with passwordless login:

ssh-keygen -o -a 100 -t ed25519
cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/id_ed25519
  • Copy your deployment user's private key to your clipboard. In your GitLab project, go to Settings > CI/CD and expand Secret variables. Paste the ssh_key as an Input variable value, and set the key to SSH_PRIVATE_KEY and save the variables.

    This allows the CD system to open an ssh connection to your server.

  • Copy your deployment user's public key to your clipboard. In your Gitlab project, go to Settings > Repository and expand Deploy Keys. Paste the public key in the Key field, and give it a name. Remember to Add Key.

    This allows GitLab to recognize your user and provides pull authorization from GitLab.

  • You may need to give your deployment user chmod and chgrp permissions. This potentially opens your server to an attack vector through the Envoy.blade.php file.

You can also add a $LOG_SLACK_WEBHOOK_URL variable if you want slack notifications upon deployment.

Installation

From your command line, composer create-project jefhar/laravel-domain-oriented will download and install the framework. From there, make will build a base docker container for your development environment. After the container has been created, make docker will create all the images needed for a complete development environment. If you do not need MailHog running just yet, make deploy will boot all containers except MailHog. To install composer dependencies, make composerinstall, and to update composer dependencies, make composerupdate. Installing npm dependencies is through make yarninstall. Use make yarnupgrade to upgrade the npm dependencies.

Of course, creating your CSS and JavaScript resources are also make commands: make npmdev, make npmprod and make npmwatch will create your resources. Similar make commands exist for phpcs, phpcbf and a pretest.

From within the php-fpm container, make refresh will drop your database, migrate all tables, and seed sample users.

Update your .env file and browse to http://localhost:8080.

composer create-project jefhar/laravel-domain-oriented blog
cd blog
make
make deploy
make composerinstall
make yarninstall
make npmdev
make pretest
make test
docker-compose exec php-fpm sh -c 'cd /application && make refresh'

Learning Laravel

Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.

If you don't feel like reading, Laracasts can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.

Laravel Sponsors

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Patreon page.

Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via taylor@laravel.com. All security vulnerabilities will be promptly addressed.

License

The Laravel framework is open-sourced software licensed under the MIT license.