Download the PHP package cxuan1225/laravel-api-from-table without Composer

On this page you can find all versions of the php package cxuan1225/laravel-api-from-table. 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-api-from-table

Laravel API From Table

Generate Laravel API classes from existing database tables.

Laravel API From Table is a database-first code generator for Laravel projects. It reads an existing table and generates the API layer around it: model, form requests, DTOs, actions, resource, and controller.


Why This Package Exists

Laravel already provides commands such as:

That command is useful for generating empty skeleton files.

However, it does not inspect your existing database table columns, nullable fields, defaults, indexes, or column types.

This package reads your database table schema and generates more useful Laravel code based on the actual database structure.


Generated Files

Running the command for a customers table can generate:

Generated API flow:


Core Idea

The package does not simply replace words inside a template.
The real value is the conversion pipeline:


Features


Requirements


Installation

Install the package via Composer:

This package is intended to be used during development, so installing it with --dev is recommended.


Usage

Generate model, requests, DTOs, actions, resource, and API controller from a database table:

The generated controller is API-oriented and wires requests, DTOs, actions, and resources together:


Dry Run

Preview the generated files without writing them:

For machine-readable previews:

The JSON output lists planned files, warnings, skipped files, route targets, and test targets.


Force Overwrite

Overwrite existing generated files:


Generate Only Model


Generate Only Requests


Generate Only DTOs


Generate Only Actions


Generate Only API Resource


Generate Only API Controller


Generate Routes

Append an API resource route to the configurable routes path, which defaults to routes/web.php:

Append the route to routes/api.php:

Generated resource URIs use kebab case by default, so a legacy_users table generates:


Generate Smoke Tests

Generate Pest endpoint smoke tests:

When --tests is combined with --api-routes, generated test requests use the configurable API prefix, which defaults to /api:


Generate Relationships

Relationship generation is opt-in. When enabled, single-column foreign keys can generate belongsTo, inverse hasMany, and whenLoaded resource fields:


Example

Given this database table:

The package can generate a model like this:

It can also generate FormRequest rules:

Command Options

Option Description
--dry-run Preview generated code without writing files
--force Overwrite existing files
--model Generate only the model
--requests Generate only FormRequest files
--dto Generate only DTO files
--actions Generate only Action files
--resource Generate only the API Resource file
--controller Generate only the API Controller file
--routes Append a Route::apiResource(...) entry to the configured routes path
--api-routes Append a Route::apiResource(...) entry to routes/api.php
--relationships Generate opt-in Eloquent relationships and whenLoaded resource fields from foreign keys
--tests Generate a Pest endpoint smoke test
--json Emit JSON output when combined with --dry-run
--all Generate all supported files, ignoring disabled defaults

Configuration

Publish the config file:

The config file will be published to:

Route naming and smoke-test prefixes can be customized:


Custom Stubs

Publish the stubs:

The stubs will be published to:

You may customize these stub files to match your own Laravel project style.

Available stubs:


Current Status

The first release focuses on generating a practical Laravel API layer from one existing database table:


Roadmap

Schema Intelligence

API Ergonomics

Customization


Testing

Run the test suite:

Or run Pest directly:


License

Laravel API From Table is open-sourced software licensed under the MIT license.


All versions of laravel-api-from-table with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^12.0|^13.0
illuminate/console Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/filesystem Version ^12.0|^13.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 cxuan1225/laravel-api-from-table contains the following files

Loading the files please wait ...