Coder Social home page Coder Social logo

ninjecture's Introduction

Ninjecture

A simple module based architecture for your Laravel projects. Ninjecture, uses two common design patterns within the module logic. The repository pattern, as the data mapping layer. And the service pattern for any kind of business logic.

Installation

Before you can install all necessary dependencies, you have first to comment out the following service provider Kreshnik\Dbtruncate\DbtruncateServiceProvider::class found in config/app.php. Once you have installed all project dependencies, using composer. You can uncomment the line again.

Folder Structure

Generics

app/Generics Here we do have all our generic classes, at th moment we do have two GenericRepository and GenericService. These generic classes, include some predefined methods to help you out. These are already inherited within every generated service, repository file.

Models

app/Models Here you have your standard eloquent models. If you use the module generate console command, the model will be generated automatically.

Modules

app/Models Here is the location of your modules, an module if made of two parts, Repositories and Services.

Module usage

Once a module has been generated, using the module generator console command. You have to add the module name to the module service provider, found in the app/Providers directory. Please have a look at Laravel's Service Container to further understand what is happening. A sample module is already provided called User, and registered with the module service provider. Once you have done this part, you will be able to inject the module service into your controller. You can find a sample controller called UserController, which uses the User module service. As you may see, I inject always the ServiceInterface of the module, into the controller method. Which means all method signatures need to be declared first into their representing interfaces. This makes it easier to test code later on, as we use Laravel's dependency injector.

Traits

app/Traits Here is the location of application traits. Currently there is just one called ResponseTypes. This trait helps you handle json responses, it is used within the UserController as demonstration.

Commands

A few helper console commands are include within the project;

  1. php artisan make:exception - Helps generate custom exceptions.
  2. php artisan make:module - Generates all necessary files for a module.
  3. php artisan db:truncate - Truncates db tables, please see the following link dbtruncate.

ninjecture's People

Contributors

kreshnik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.