Download the PHP package ug-php/clean-architecture-core without Composer

On this page you can find all versions of the php package ug-php/clean-architecture-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package clean-architecture-core

Core Library for Clean Architecture in PHP

Introduction

This documentation guides you through the utilization of the core library for implementing clean architecture in PHP. We'll explore the creation of custom application requests and use cases, paying special attention to handling missing and unauthorized fields.

Practical examples are provided using code snippets to showcase the library's usage in building a modular and clean PHP application.

Prerequisites

Ensure that you have the following:

Installation

To install the core library, run the following command in your project directory:

Core Overview

Application Request

Request serve as input objects, encapsulating data from your HTTP controller. In the core library, use the \Urichy\Core\Request\Request class as the foundation for creating custom application request objects. Define the expected fields using the requestPossibleFields property.

Handling unauthorized fields:

Handling missing fields:

When request successfully created.

Presenter

Presenter handle the output logic of your use case. Extend \Urichy\Core\Presenter\Presenter and implement \Urichy\Core\Presenter\PresenterInterface.

Response

Response encapsulate the data returned by use cases. They include status information, messages, and any relevant data. Use \Urichy\Core\Response\Response to create use case responses.

Use Case

Use cases encapsulate business logic and orchestrate the flow of data between requests, entities, and presenters. Extend the \Urichy\Core\Usecase\Usecase class and implement \Urichy\Core\Usecase\UsecaseInterface with the execute method.

@see example below

Exception

When an exception is thrown during processing, you can use some method to handle the exception data.

How to create an exception ?

  1. Create an exception class that extends \Urichy\Core\Exception\Exception

  2. Throw an exception when something has gone wrong and handling it.

Example Usage

From Scratch (PHP Without a Framework)

Project Structure

Code Examples

public/index.php
src/Controller/BookController.php
src/Request/BookRecordRequest.php
Using beberlei/assert validation library
Using Symfony Validator library
src/Presenter/JsonResponsePresenter.php
src/Presenter/HtmlResponsePresenter.php
src/UseCase/RegisterBookUsecase.php
src/Response/Response.php

Example with Symfony

Project Structure

Code Examples

src/Controller/BookController.php

Example with Laravel

Project Structure

Code Examples

app/Http/Controllers/BookController.php

With request and presenter

Without presenter, but with request.

Without request and presenter

Unit Tests

Command to Run Unit Tests

License

Information on Copyright and MIT License


All versions of clean-architecture-core with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ramsey/uuid Version ^4.7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ug-php/clean-architecture-core contains the following files

Loading the files please wait ....