Git Product home page Git Product logo

adr-blog's Introduction

ADR Blog example

  1. Introduction
  2. Installation
  3. Structure
  4. Extend the project

Introduction

The next project is a code example for a Blog project based on Action-Domain-Responder and Symfony 4.

Installation

In order to get the project working:

  1. Clone the repository
  2. Execute composer install
  3. Configure the database access in your .env file
  4. Create the database: bin/console doctrine:database:create
  5. Run Migrations: bin/console doctrine:migration:migrate
  6. You can import the Postman Collection file on postman/ADR-Blog.postman_collection.json

3. Structure

The project has the next structure:

src
|__  Action
|  |__  Author
|  |__  Post
|
|__  Domain
|  |__  Entity
|  |__  Module
|  |  |__  Author
|  |  |  |__  Application
|  |  |  |  |__  CreateAuthor
|  |  |  |  |__  DeleteAuthor
|  |  |  |  |__  GetAuthor
|  |  |  |  |__  GetAuthors
|  |  |  |  
|  |  |  |__  Domain
|  |  |  |__  Infratructure
|  |  | 
|  |  |__  Post
|  |     |__  Application
|  |     |  |__  CreatePost
|  |     |  |__  DeletePost
|  |     |  |__  GetPost
|  |     |  |__  GetPosts
|  |     |  
|  |     |__  Domain
|  |     |__  Infratructure
|  |
|  |__  Shared
|     |__  Http
|     |__  Uuid
|
|__  Migrations
|__  Responder

3.1. Actions

Here we have the endpoints which allow us to perform some actions in the blog, like:

  • List posts paginated
  • Get a single post
  • Delete a post
  • Create a new post

3.2. Domain

In this directory we can found the two modules that the application is composed. Each module has exactly 3 folders:

  • Application: Contains all the use cases
  • Domain: Contains all the the interfaces needed to allow the talk between application and infrastructure
  • Infrastructure: Contains all the concrete implementations of the domain contracts

Here we can als found two more directories:

  • Entities: Where we store our models
  • Shared: Where we store interfaces and classes of shared use, like exceptions or checkers.

3.3. Responder

Last but not least important, in the responder folder we can found all the classes that handle the responses.

4. Extend the project

If you want to play with the code and add your self actions, it's very easy! Take for example the case you want add an edit author action:

You just need to:

  1. Create your action (in the Action\Author folder)
  2. Create your use case (in the Domain\Module\Author\Application\EditAuthor)
  3. Think if you need an ad-hoc responder or you can use an existent (for this case, the ResourceResponder will do the job)
  4. Register the route for your action in config/routes/author.yml

That's all!

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.