PHPackages                             axyr/laravel-tractor - 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. axyr/laravel-tractor

ActiveLibrary[API Development](/categories/api)

axyr/laravel-tractor
====================

Opiniated Laravel CRUD generator for a Module/Repository/Filter based CRUD setup.

1.5(10mo ago)5533↓25%3MITPHPPHP ^8.2CI failing

Since Aug 16Pushed 9mo ago1 watchersCompare

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

READMEChangelog (1)Dependencies (5)Versions (6)Used By (0)

🚜 Laravel Tractor - Another Laravel API Module Generator
========================================================

[](#-laravel-tractor---another-laravel-api-module-generator)

Scaffold a Laravel module structure for JSON API's.

[![](docs/img/tractor.jpg)](docs/img/tractor.jpg)

Introduction
------------

[](#introduction)

Laravel Tractor is another module scaffolder for generating the basic PHP classes commonly used for JSON API's. The scaffolder is mainly targetted on stand alone API's without any Blade, Livewire or any other frontend library.

[![Latest Version on Packagist](https://camo.githubusercontent.com/69f28e3fd88144a7bafa8760376902cdad223c4121e0e8caaa1953b2eb014810/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617879722f74726163746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/axyr/tractor) [![Tests](https://github.com/axyr/laravel-tractor/actions/workflows/run-tests.yml/badge.svg)](https://github.com/axyr/laravel-tractor/actions/workflows/run-tests.yml)

After installing, you can generate all required files for a working CRUD based module:

```
php artisan tractor:generate Post
```

Above command will generate a basic module structure with all the files needed for a model based JSON API.

The module will have boilerplate tests that tests all the permission authorization, database operations and filters.

```
📂 app
📂 app-modules
 ┗ 📂 Posts
   ┗ 📂 src
     ┗ 📂 Factories
       ┗ 📄 PostFactory.php
     ┗ 📂 Filters
       ┗ 📄 PostFilter.php
     ┗ 📂 Http
       ┗ 📂 Controllers
         ┗ 📄 PostController.php
       ┗ 📂 Requests
         ┗ 📄 PostRequest.php
       ┗ 📂 Resources
         ┗ 📄 PostResource.php
     ┗ 📂 Models
       ┗ 📄 Post.php
     ┗ 📂 Policies
       ┗ 📄 PostPolicy.php
     ┗ 📂 Repositories
       ┗ 📄 PostRepository.php
     ┗ 📂 Seeders
       ┗ 📄 PostSeeder.php
   ┗ 📂 tests
     ┗ 📂 Filters
       ┗ 📄 PostFilterTest.php
     ┗ 📂 Http
       ┗ 📂 Controllers
         ┗ 📄 PostControllerAuthorizationTest.php
         ┗ 📄 PostControllerTest.php
   ┗ 📄 composer.json
   ┗ 📄 routes.php
📂 database
┗ 📂 migrations
  ┗ 📄 2024_08_16_135340_create_posts_table.php

```

Examples
--------

[](#examples)

A full example of a generater module can be found here:

TODO

We generate the bare minimum, but workable and testable code, some examples:

### Model

[](#model)

```
