New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

jamosaur/foundation

Foundation for API's in Laravel
4,458

Larablocks Analysis

jamosaur/foundation works with Laravel 10 to 13 (latest release 1.0.1, May 22, 2026).

Laravel 8 and 9 in earlier releases.

Promising: maintained and up to date, meets 2 of 4 checks; not yet widely used.

  • Works with Laravel 13, the current version
  • Released in the last 12 months (May 22, 2026)
  • 162 downloads a month (needs 10,000)
  • 0 GitHub stars (needs 100)

State

Maintained
  • Last stable release: May 22, 2026.
  • 2 releases in the last 12 months.
  • First released: Sep 30, 2021.
  • Monthly downloads: 162.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 29, 2026.

Install
composer require jamosaur/foundation
Latest Version:1.0.1
PHP:^8.2
Laravel:10 – 13
Older releases:8 · 9
Last Updated:May 22, 2026
Links: GitHub  ·  Packagist
Maintainer: jamosaur

Foundation


What is this?

This is the base that I like to use for constructing API's with Laravel.

It is essentially a wrapper for Spatie's laravel-fractal.


Installation


  1. composer require jamosaur/foundation
  2. Update your API controllers to extend Jamosaur\Foundation\ApiController. This extends the default Laravel controller but also adds more methods that we will use.
  3. Update your API middleware in app\Http\Kernel.php to use Jamosaur\Foundation\Middleware\ApiRequestMiddleware

Example Usage

Controller

<?php

declare(strict_types=1);

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\JsonResponse;
use Jamosaur\Foundation\ApiController;

class UserController extends ApiController
{
    public function index(): JsonResponse
    {
        $users = User::all();
        
        // By default, this will attempt to transform the data with
        // `\App\Transformers\UserTransformer`. The package takes replaces
        // the `Controller` in the controller name with Transformer
        // and attempts to load it from the `\App\Transformers\ namespace.
        return $this->transformCollection('users', $users)
            ->respond();
    }
    
    public function differentNamespace(): JsonResponse
    {
        $users = User::all();
        
        // You can define a different namespace for transformers.
        return $this->setTransformerNamespace('\\App\\Domain\\Transformers')
            ->transformCollection('users', $users)
            ->respond();
    }
    
    public function chainingTransformers(): JsonResponse
    {
        $user = User::all();
        $posts = Post::all();
        $photo = Photo::query()->first();
        
        // You can also chain methods to transform multiple
        // sets of data.
        return $this->setTransformer(new UserTransformer())
            ->transformCollection('users', $users)
            ->setTransformer(new PostTransformer())
            ->transformCollection('posts', $posts)
            ->setTransformer(new PhotoTransformer())
            ->transformItem('photo', $photo)
            ->respond();
    }
    
    public function definedTransformer(): JsonResponse
    {
        $users = User::query()->with('profile')->get();
        
        // You can override which transformer is used, and also pass in
        // any includes.
        return $this->setTransformer(new CustomTransformer(), ['profile'])
            ->transformCollection('users', $users)
            ->respond();
    }
}

Important Notes

  • Transformers MUST implement Jamosaur\Foundation\Contracts\TransformerContract and extend League\Fractal\TransformerAbstract

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

670,032,257 9,703
laravel/framework

The Laravel Framework.

640,572,096 35,338
laravel/tinker

Powerful REPL for the Laravel framework.

546,909,908 7,440
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

465,816,364 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

431,187,642 4,660

Version History

Version Released PHP Laravel License
1.0.1 ^8.2 ^10.0|^11.0|^12.0|^13.0
1.0.0 ^8.2 ^10.0|^11.0|^12.0
0.6 ^8.0|^8.1|^8.2 ^8.0|^9.0|^10.0|^11.0|^12.0
0.5 ^8.0|^8.1|^8.2 ^8.0|^9.0|^10.0|^11.0
0.4 ^8.0|^8.1|^8.2 ^8.0|^9.0|^10.0