Laravel API architecture builder based on artisan commands.

Overview

🧑‍🔬 API-Formula

Laravel API architecture builder based on artisan commands.

This package provides a nice and fluent way to generate combined controllers, models, migrations, requests, resources, repositories and services, thus keeping the code well structured and organized.


Installation

Install the package with composer, execute the setup command and register the RepositoryServiceProvider.php file in config > app.php under the providers array.

composer require klisica/api-formula
php artisan api-formula:setup
'providers' => [
    ...
    App\Providers\RepositoryServiceProvider::class,
    ...
 ],

Next, in routes > api.php add // @API_FORMULA_AUTOIMPORT comment in order to enable auto importing of resource routes. For example, I like to bind the importing in middleware group:

...
Route::midleware('auth:sanctum')->group(function () {
    Route::resource('job_posts', 'JobPostController')->parameters(['' => 'job_post']);
    ...
    // @API_FORMULA_AUTOIMPORT
});

To publish the config file run:

php artisan vendor:publish --provider="KLisica\ApiFormula\Providers\ApiFormulaServiceProvider"

Usage

To start the API builder run the following command:

php artisan api-make:formula

To manually create specific file you can use one of these commands:

php artisan api-make:model ModelName
php artisan api-make:migration create_example_table
php artisan api-make:repository RepositoryName --model=ModelName
php artisan api-make:service ServiceName
php artisan api-make:request RequestName
php artisan api-make:controller ControllerName --model=ModelName

Other external packages used with this package:


Filtering and sorting on models

Each model is using a custom Filterable trait, which is handling simple query-based filtering and sorting functions on models.

  • Filters are accepted in format column[operator]=value.
  • To filter by relations the format is relationName|column[operator]=value (note the | separator in between).
  • Free-text filter is by default _text query parameter.

JSON example:

{
    page: 1,
    per_page: 10,
    sort_by: ['created_at', 'desc'],
    'name[equal]': 'Name example',
    'relation|name[equal]': 'Relation name example',
    '_text': 'Search for something'
74

}

Raw URL-Query example:

http://api-formula.test/api/job_posts?per_page=10&page=1&sort_by[0]=created_at&sort_by[1]=desc&name[equal]=Name example&relation|name[equal]=Relation name example
You might also like...
Dispatch Laravel jobs via Artisan
Dispatch Laravel jobs via Artisan

This package can register jobs as Artisan commands. All you need to do is let your job implement the empty ArtisanDispatchable interface.

📦 Adds Laravel Packages Support to Lumen and Vendor Publish Artisan Command.
📦 Adds Laravel Packages Support to Lumen and Vendor Publish Artisan Command.

Laravel Package Support for Lumen: Makes Lumen compatible with Laravel Packages. You can use any Laravel Packages in Lumen by installing Larasupport Package.

Create Laravel views (blade template) using 'php artisan' command-line interface
Create Laravel views (blade template) using 'php artisan' command-line interface

About LaraBit Have you ever wonder to create Laravel views (Blade Templates) using the same type of artisan commands that you usually use to create ne

Generate services in Laravel with the artisan command
Generate services in Laravel with the artisan command

Laravel Service Generator Quickly generate services for your projects! Table of Contents Features Installation Usage Generate services Generate servic

A Laravel Artisan SQL Interactive Interface
A Laravel Artisan SQL Interactive Interface

sqli A Laravel 4 & 5 Artisan SQL Interactive Interface, plus a handful of Artisan commands to execute SQL queries. sqli It's like tinker for SQL, just

An artisan command for using multiple environment configurations in Laravel 5

Laravel 5 env An artisan command for managing multiple .env of your Laravel 5 app. Installation Copy EnvCommand.php to app/Console/Commands/ of your L

This package is to add a web interface for Laravel 5 and earlier Artisan.
This package is to add a web interface for Laravel 5 and earlier Artisan.

Nice Artisan This package is to add a web interface for Laravel 5 and earlier Artisan. Installation Add Nice Artisan to your composer.json file : For

A nice GUI for Laravel Artisan, ready out of the box, configurable and handy for non-CLI experienced developers.

Artisan UI A nice GUI for Laravel Artisan, ready out of the box, configurable and handy for non-CLI experienced developers. Supported commands must be

Generate services and contracts in Laravel with the artisan command
Generate services and contracts in Laravel with the artisan command

What does it do? This package adds a new php artisan make:service {name} {--N|noContract} command. It will create a service file and its contract (int

Releases(v1.0.2)
Owner
Krševan Lisica
Full-Stack Web Developer
Krševan Lisica
A bookmarkable, searchable cheatsheet for all of Laravel's default Artisan commands.

artisan.page A bookmarkable, searchable cheatsheet for all of Laravel's default Artisan commands. Generation The generation of the manifest files is d

James Brooks 284 Dec 25, 2022
This Laravel Nova tool lets you run artisan and bash commands directly from Nova 4 or higher.

Laravel Nova tool for running Artisan & Shell commands. This Nova tool lets you run artisan and bash commands directly from nova. This is an extended

Artem Stepanenko 17 Dec 15, 2022
Execute Laravel Artisan commands via REST APIs and HTTP requests safely.

Artisan Api There might be some times you wanted to execute an Artisan command, but you did not have access to shell or SSH. Here we brought REST API

Alireza 11 Sep 7, 2022
📝 Artisan Menu - Use Artisan via an elegant console GUI

?? Artisan Menu Use Artisan via an elegant console GUI Features Run built-in and custom Artisan commands from a console GUI Prompts to enter required

Jordan Hall 149 Dec 29, 2022
📝 Artisan Menu - Use Artisan via an elegant console GUI

?? Artisan Menu Use Artisan via an elegant console GUI Features Run built-in and custom Artisan commands from a console GUI Prompts to enter required

Jordan Hall 148 Nov 29, 2022
A package that makes it easy to have the `artisan make:` commands open the newly created file in your editor of choice.

Open On Make A package that makes it easy to have the artisan make: commands open the newly created file in your editor of choice. Installation compos

Andrew Huggins 94 Nov 22, 2022
Hexagonal architecture for Laravel

Laravel Hexagonal Laravel package that allows modifying the folder structure proposed by Laravel in its initial installation by a structure based on H

null 3 Apr 30, 2022
A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

Laravel MongoDB This package adds functionalities to the Eloquent model and Query builder for MongoDB, using the original Laravel API. This library ex

Jens Segers 6.3k Jan 7, 2023
A DynamoDB based Eloquent model and Query builder for Laravel.

Laravel DynamoDB A DynamoDB based Eloquent model and Query builder for Laravel. You can find an example implementation in kitar/simplechat. Motivation

Satoshi Kita 146 Jan 2, 2023
👀 Manage your views in Laravel projects through artisan

Artisan View This package adds a handful of view-related commands to Artisan in your Laravel project. Generate blade files that extend other views, sc

Sven Luijten 842 Dec 29, 2022