Download the PHP package bjerke/laravel-bread without Composer

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

Laravel Bread

A library to easily handle BREAD (Browse, Read, Edit, Add, Delete) operations through a JSON Rest API. Define model definitions, performs validations and provides default controller routes.

This package makes use of the API Query Builder from https://github.com/jesperbjerke/laravel-api-query-builder

Installation

Configuration

There is not much to configure, but one thing that can be configured is what namespace to use for your models (used when trying to lookup the model in the controller). It is preconfigured to use \App\Models\. If you don't need to change any of the default configuration options there's no need to publish this configuration.

If you do want to change the default namespace however, you need to publish the configuration file from this library so you can change it in your own application. To do this run the following artisan command:

You will now have a bread.php config file in /config where you can change the configuration values.

Other configuration items are default field groups available to all models as well as some options related to TUS uploads.

Usage

To start using this package, you need to create your own controller class, name it in singular matching the model it's affecting. For example UserController will lookup the User model automatically. If you don't follow this pattern, you can define the $modelName property on the controller.

Extend your controller on BreadController from this package. Then in your model, use the QueryBuilderModelTrait and BreadModelTrait.

Lastly, define the API endpoints in your router.

Remember to only define the endpoints that you actually want to use. And set proper authentication and authorization rules.

If you want to provide field definitions and automatic validation etc, you need to use the FieldDefinition trait and define the fields on your model.

The above definition together with the routes will allow you to post the following to /users to create a new user:

Note the data you send is expected to be within the data property.

More about available field types and how they work is described in each fields docblock in src/Traits/FieldDefinition.php.

Modifying queries in BREAD controller endpoints

You can hook into the query builder and append your own rules on endpoints that fetch data from the database.

Example:

Run logic before/after Updating/Deleting/Attaching/Detaching

The breadcontroller provides hooks to allow you to run custom logic before the actual saving proceeds. If you want to stop the execution, throw an appropriate exception. Use the hooks by implementing the endpoint method in your controller, and passing a closure to the parent method. This works on all endpoint methods.

Example:

Saving files/images

In order for the built-in functionality of storing files and/or images, this package requires the https://github.com/spatie/laravel-medialibrary to be installed and configured.

Add files/images:

Remove files/images:

TUS uploads

There is build in functionality to support uploads using the TUS protocol. To enable TUS uploads, you need to install the package https://github.com/ankitpokhrel/tus-php in addition to the media library package specified above.

You can then use a TUS client like https://github.com/tus/tus-js-client or https://uppy.io/.

When submitting the files, you send the unique upload key received from the TUS server (a UUID4 string) instead of base64. Note that it is expected that the file has already been uploaded through TUS and exists on the server before this request is sent.

Cleaning orphaned TUS files

Add $schedule->command('bread:clean-tus --force')->daily() to your scheduler to automatically clean up orphaned/aborted files.


All versions of laravel-bread with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-json Version *
bjerke/api-query-builder Version ^1.0
illuminate/support Version ^8.0 | ^9.0
illuminate/http Version ^8.0 | ^9.0
illuminate/database Version ^8.0 | ^9.0
illuminate/routing Version ^8.0 | ^9.0
illuminate/validation Version ^8.0 | ^9.0
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 bjerke/laravel-bread contains the following files

Loading the files please wait ....