PHPackages                             fariddomat/auto-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. fariddomat/auto-api

ActiveLaravel-package[API Development](/categories/api)

fariddomat/auto-api
===================

Automates RESTful API generation for Laravel.

02PHP

Since Mar 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/fariddomat/auto-api)[ Packagist](https://packagist.org/packages/fariddomat/auto-api)[ RSS](/packages/fariddomat-auto-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Auto-API
========

[](#auto-api)

Auto-API is a Laravel package that automates the generation of RESTful API endpoints for your models with a single interactive command. It creates models, migrations, controllers, routes, and OpenAPI specifications, supporting features like file uploads, pagination, soft deletes, searchable fields, and relationship data for `select` fields—all with a colorful CLI experience.

---

Installation
------------

[](#installation)

Install Auto-API via Composer:

```
composer require fariddomat/auto-api:dev-main
```

No additional setup is required—the package auto-registers its command via the service provider.

Usage
=====

[](#usage)

Generate an API Module
======================

[](#generate-an-api-module)

Use the interactive make:auto-api Artisan command to generate an API module:

```
php artisan make:auto-api
```

Interactive Example
===================

[](#interactive-example)

```
    Welcome to AutoAPI Generator! Let's create your API step-by-step.
    Model name? (e.g., Post; must start with a capital letter): Product
    Define fields for Product (e.g., title:string, user_id:select). Leave blank to finish.
    Enter a field: name:string
    Enter a field: category_id:select
    Enter a field: image:image
    Enter a field:
    API version? (e.g., v1, v2; default: v1): v1
    Enable soft deletes? (Default: No) [N/y]: y
    Enable search functionality? (Default: No) [N/y]: y
    Searchable fields (comma-separated, from: name, category_id, image): name
    Middleware (comma-separated, e.g., auth:api,throttle; leave blank for none): auth:api
    API Settings:
    Model: Product
    Fields: name:string, category_id:select, image:image
    Version: v1
    Soft Deletes: Yes
    Search Enabled: Yes
    Searchable Fields: name
    Middleware: auth:api
    Proceed with these settings? [Y/n]:
    Generating Auto API for Product...
```

This generates:

- **Model**: Product with $fillable, $searchable, validation rules(), and relationships.
- **Migration**: products table with id, name, category\_id (foreign key), image, deleted\_at, timestamps.
- **Controller**: ProductApiController with RESTful methods (index, create, store, show, edit, update, destroy, restore).
- **Routes**: API routes in routes/api.php under v1 with auth:api middleware.
- **OpenAPI**: openapi/Product.json spec documenting all endpoints.

---

### Fields

[](#fields)

Define fields interactively with these supported types:

Field TypeDescriptionExample UsagestringText inputname:stringdecimalDecimal number (e.g., prices)price:decimalintegerInteger numberquantity:integertextLonger text fielddescription:textselectForeign key with relationshipuser\_id:selectbooleanTrue/false valueis\_active:booleanfileSingle file upload (e.g., PDF)manual:fileimageSingle image uploadthumbnail:imageimagesMultiple image uploadsgallery:imagesModifiers like :nullable can be appended (e.g., name:string:nullable).

---

### Features

[](#features)

✔ **Interactive CLI**: Generate APIs with a colorful, step-by-step interface.
✔ **Automatic API Generation**: Creates models, migrations, controllers, routes, and OpenAPI specs.
✔ **Customizable Fields**: Supports various data types, including relationships and file uploads.
✔ **Pagination**: index endpoint returns paginated results (default 15 per page).
✔ **Searchable Fields**: Filter index results with a search query parameter.
✔ **Soft Deletes**: Optional soft delete support with a restore endpoint.
✔ **File Uploads**: Handles file, image, and images fields with ImageHelper or Laravel storage.
✔ **Relationships**: Returns related model data (e.g., users) in create and edit responses.
✔ **Middleware**: Optional middleware application (e.g., auth:api, throttle).
✔ **OpenAPI Spec**: Generates a detailed OpenAPI 3.0 specification for each API.

---

### API Endpoints

[](#api-endpoints)

MethodEndpointDescriptionGET/v1/{model}List all records (paginated)GET/v1/{model}/createGet data for creating a recordPOST/v1/{model}Create a new recordGET/v1/{model}/{id}Show a specific recordGET/v1/{model}/{id}/editGet data for editing a recordPUT/v1/{model}/{id}Update a specific recordDELETE/v1/{model}/{id}Delete a specific recordPOST/v1/{model}/{id}/restoreRestore a soft-deleted record#### Pagination

[](#pagination)

- Use ?per\_page={n}&amp;page={m} to adjust results (e.g., GET /v1/products?per\_page=10&amp;page=2).

#### Search

[](#search)

- Use ?search={term} to filter results (e.g., GET /v1/products?search=phone).

#### File Uploads

[](#file-uploads)

- Use multipart/form-data for POST and PUT requests with file fields: bash

    `curl -X POST /v1/products \     -F "name=Phone" \     -F "image=@phone.jpg" \     -F "gallery[]=@img1.jpg" \     -F "gallery[]=@img2.jpg"`

---

### File &amp; Image Handling

[](#file--image-handling)

#### Single File Upload (file)

[](#single-file-upload-file)

Stores files in storage/app/public/uploads/{model}:

`if ($request->hasFile('manual')) {    $validated['manual'] = $request->file('manual')->store('uploads/products', 'public');}`

#### Single Image Upload (image)

[](#single-image-upload-image)

Uses ImageHelper if available, otherwise falls back to storage:

`if ($request->hasFile('image') && class_exists('App\Helpers\ImageHelper')) {    $validated['image'] = ImageHelper::storeImageInPublicDirectory($request->file('image'), 'uploads/products');} elseif ($request->hasFile('image')) {    $validated['image'] = $request->file('image')->store('uploads/products', 'public');}`

#### Multiple Image Uploads (images)

[](#multiple-image-uploads-images)

Processes multiple files into a JSON-encoded array:

`if ($request->hasFile('gallery') && class_exists('App\Helpers\ImageHelper')) {    $validated['gallery'] = [];    foreach ($request->file('gallery') as $image) {        $validated['gallery'][] = ImageHelper::storeImageInPublicDirectory($image, 'uploads/products');    }    $validated['gallery'] = json_encode($validated['gallery']);} elseif ($request->hasFile('gallery')) {    $validated['gallery'] = json_encode(array_map(fn($file) => $file->store('uploads/products', 'public'), $request->file('gallery')));}`

---

### Configuration

[](#configuration)

- **Customize Generated Files**:
    - Edit models in app/Models/.
    - Modify controllers in app/Http/Controllers/.
    - Adjust migrations in database/migrations/.
    - Update the OpenAPI spec in openapi/.
- **File Storage**: Configure Laravel’s public disk or use ImageHelper for custom file handling.

---

### Contribution

[](#contribution)

Contributions are welcome! Submit issues, bug fixes, or pull requests via GitHub to improve Auto-API.

---

### License

[](#license)

Auto-API is licensed under the [MIT License](LICENSE). See the LICENSE file for details.

text

``

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/67d09c13658910630a603e0e8e6937e392d6ab5ee8f6d5450a2b4d1b56768a03?d=identicon)[fariddomat](/maintainers/fariddomat)

---

Top Contributors

[![farid-domat](https://avatars.githubusercontent.com/u/239963924?v=4)](https://github.com/farid-domat "farid-domat (4 commits)")

### Embed Badge

![Health badge](/badges/fariddomat-auto-api/health.svg)

```
[![Health](https://phpackages.com/badges/fariddomat-auto-api/health.svg)](https://phpackages.com/packages/fariddomat-auto-api)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
