Skip to content

Tivix/laravel-tools

Repository files navigation

Kellton Laravel Tools

This package was created in mind to be used internally. We will never provide backward compatibility for this package. This package probably have many bugs that we are not aware of, or we don't use this package in a way that you do. If you want to use this package, you should fork it and use your own version. Happy to get any feedback, or pull requests, but don't expect us to merge them (sorry!).

This package provides a set of tools to help you develop Laravel applications.

Installation

You can install the package via composer:

composer require kellton/laravel-tools

Development

To start developing first you must install the dependencies:

docker run --rm -v $(pwd):/app composer install

Testing

To test the package you can run:

docker run --rm -v $(pwd):/app -w /app php:8.2-cli vendor/bin/phpunit

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Features

Undefined

In PHP, we are still missing a way to define undefined variables. The Undefined class is a solution for that.

Builder

The Builder class is a wrapper around the Laravel's Eloquent Builder, it provides a set of methods to help you build complex queries.

Command

The Command class is a wrapper around the Laravel's Command class, that allowing you to use Dependency Injection in your commands.

Data

The Data feature is a extended version of Value object that can be used to represent a data structure.

This solution allows you to validate input data using Laravel's validation rules.

Dependency

The Dependency feature allowing you Lazy Dependency Injection in your classes.

Standard way of using Dependency Injection in Laravel is to use the constructor to inject dependencies, but whenever a classes is created, all the dependencies are also resolved. This can be a problem when you have a lot of dependencies, and you don't need all of them in every case.

In this case we resolve dependencies only when they are first used.

Action

The Action feature is a wrapper around the Laravel's Controller and Service classes, that allowing you to skip huge amount of boilerplate code.

Initializer

The Initializer feature allows you to initialize your project with a set of predefined data.

Initializer needs to be impotent, so it can be run multiple times without any side effects. So you are able to add new data to the initializer without worrying about breaking existing data. As this is only mechanism to initialize data, you are responsible for keeping queries impotent.

OpenApi documentation

The OpenApi documentation feature allows you to generate OpenApi documentation for your API.

Read model

The Read model feature allows you to create a read models for your application.

Directory structure

Builder

The Builder directory contains a set of commonly used traits and Eloquent Builders.

Commands

The Commands directory is a place for a commonly used commands.

Data

The Data directory contains a set of commonly used data classes.

Enums

The Enums directory contains a set of commonly used enums.

Exceptions

The Exception directory contains a set of commonly used exceptions.

Features

The Features directory contains a set of commonly used features. If you need to create a feature that is composed of multiple files you can create a directory with the same name as the feature and put all the files there.

Helpers

The Helpers directory contains a set of commonly used helpers.

Models

The Models directory contains a set of commonly used models.

Rules

The Rules directory contains a set of commonly used rules.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages