Download the PHP package gerson/laravel-base without Composer

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

Total Downloads Latest Stable Version License

Introduction

Laravel Base is a package that aims to facilitate the development of applications using the Laravel framework. It is a package that provides a base for the development of applications, providing a structure for the development of services, repositories and controllers, as well as providing a base for the development of resources.

Requirements

How to install

To install the package, simply run the following command in your project's root directory.

Let's open the file

and search for

to the end of the array, just add

In your project, within App create two directories. Services e Repositories

In the "Controller.php" file within app/Http/Controllers Replace

by

And add it to the file header.

How to use

Using it is very simple, you can generate your resources with a simple command. The only requirement is that you have already generated your MODEL.

Just run the command

and answer questions.

Suggestion: Use the name of the Model in the first question (which will ask for the name of the service). If you say yes to all items, at the end you will have one Repository

1 - Service 1 - Controller. (Already with CRUD ready to be executed).

How it works

The get() method will fetch all items from your model, you can apply the relationships, just create a function in your model with the name of scopeWithRelations, follow the example:

Thus, it will be applied to the INDEX and SHOW method.

As for persistence (Store and Update), it will persist if the indexes coming from the request are the same as the name of the columns in the database. Note: your Fillable needs to have these columns, that's where it will extract it from. Additionally, you can override the store and update method in your Service. thus applying its specific rules.

Some features

In your controller, you can configure validation as follows:

1 - Controllers

Therefore, any store or update request will apply these rules. But then, we have a problem. By informing that the email must be unique, the update will break saying that the email already exists, since validation is applied before, To resolve this, we have two options, the first is to override the email rule for when it is an update, as follows:

This way, it will merge between the two arrays, when updated and the email will continue to be required, however, without unique validation. Furthermore, it will maintain the other rules, for cpf and password, if I want to remove them, I can do it as follows:

This way, using all 3, the result will be, you will only apply $validators when creating a new record and when updating, it will only require you to fill in the E-mail.

2 - Services

In our previous version, we needed to do this to save something at multilevel:

With the new version, we no longer need this, see the example:

I just need to inform the Repository that it becomes the "child" of the object and at what point it should be persisted, before or after the main one.

3 - Repository

If I need to store an image, considering that I will receive it in base64 via JSON request, in the following example:

I can configure the following in my repository:

This way, it will convert the base64 into a file, save it in storage at the pre-defined path and return the URL to access the file and add this to save it in the database if there is a column with the name "logo " in that case. something like:


All versions of laravel-base with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
yajra/laravel-datatables-oracle Version ^11.1.0
spatie/laravel-query-builder Version ^6.0.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 gerson/laravel-base contains the following files

Loading the files please wait ....