Download the PHP package rateb/structure without Composer

On this page you can find all versions of the php package rateb/structure. 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 structure

laravel-structure-craft

Table of Contents

Getting started

Installation

To install the package, run the following command:

Registering the Service Provider

To use the features provided by the rateb-structure package, you need to register the StructureServiceProvider. Follow these steps:

  1. Open the config/app.php file in your Laravel project.
  2. Locate the providers array in the file.
  3. Add the following line to the array:

Example of the Providers Array

After adding the StructureServiceProvider, your providers array in the config/app.php file should look something like this:

Key Concepts

1. Repository Pattern:

The Repository layer provides an abstraction for handling data persistence and retrieval. Each Model in the system will have its own Repository to encapsulate the business logic related to that model. This structure promotes separation of concerns, where the controller handles user requests, the Repository manages the data access, and DTO handles data transfer.

2. Data Transfer Object (DTO):

The DTO is responsible for transporting data between different layers of the application, such as from the Request to the Repository. This ensures that the data is clean, validated, and transformed as needed before it reaches the business logic layer.

3. Filters and Search:

To facilitate flexible data retrieval, the package supports filtering and searching via pre-defined filter classes and searchable fields. This enables users to query and filter models without bloating the controller with query logic.

4. SOLID Principles:

The package adheres to SOLID principles, particularly:

Usage

Project Structure

Routing Configuration

In your routes/web.php (or routes/api.php depending on your application structure), add the following routes to handle user creation and retrieval:

Explanation of Routes

UserController.php

The UserController handles requests from the user and interacts with the UserRepo repository for retrieving or storing user data.

UserController.php

UserRepo.php

The UserRepo is responsible for handling all database interactions related to the User model. It extends the BaseRepo to benefit from common repository functionalities, such as filtering and searching.

Creating Repository

To create a Repository and a Data Transfer Object (DTO), you can use the following Artisan command:

in path App\Http\Repositories

Filterable Fields

Searchable Fields

Relations and Relation Fields

UserData.php (DTO)

The UserData class is responsible for collecting and validating data from requests before passing it to the repository.

Creating DTO

To create a Repository and a Data Transfer Object (DTO), you can use the following Artisan command:

in path App\Http\DTOs

fromRequest()

Extending the DTO

To extend the DTO to handle new data fields:

  1. Modify the UserData::fromRequest() method to include the new fields.
  2. Ensure these fields are available in the incoming request.

To create them together ( DTO , Repository )

Important Note

The name of the repository and DTO should match the name of the model. In this case, User refers to the User model. This consistency helps maintain organization within your codebase, making it easier to manage and understand the relationships between models, repositories, and DTOs.

StatusUserFilter.php (DTO)

Creating a Filter

To create a filter, you can use the following Artisan command:

StatusUserFilter.php

The StatusFilter class filters users by their status. This is an example of how filters are applied in the repository to ensure clean, reusable, and flexible querying.

apply()

This command will generate a new filter class named StatusUserFilter. Filters are used to define the criteria for retrieving or manipulating data, allowing you to encapsulate and organize your query logic effectively.

Make sure to implement the necessary methods within the generated filter class to suit your application's requirements

To add a new filter to any repository:

  1. Create a new filter class (e.g., AgeFilter).
  2. Define the filter logic in the apply() method.
  3. Add the filter to the filtersKeys array in the repository.

Contact

Thank You Message

Dear Users,

I would like to extend my heartfelt thanks to you for using our package. We truly appreciate your time and effort in reading the documentation and engaging with our content.

If you have any questions or feedback, please feel free to reach out to us via email:

Email: [[email protected]]

We are here to assist you and look forward to hearing your thoughts!


All versions of structure with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
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 rateb/structure contains the following files

Loading the files please wait ....