Download the PHP package saimain/laravel-mock-api without Composer

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

Laravel Mock API

File-backed mock API responses with a zero-config management panel — for building frontend features against endpoints your backend hasn't built yet.

No database, no migrations. Every mock endpoint (method, path, status code, response body) is stored in a single JSON file and served by a catch-all route. A built-in panel lets you create, edit, and delete mocks through the browser, with a syntax-highlighted JSON editor — no dependency on your host app's frontend stack (works the same whether your app uses Blade, Inertia+React, Vue, or nothing at all).

Requirements

Installation

That's it. The service provider is auto-discovered — no manual registration, no .env changes required. Out of the box:

Usage

  1. Visit /mock-panel in your browser — it opens straight into a new endpoint form, with existing endpoints listed in the sidebar (click one to edit it, or the + button to start another).
  2. Fill in:
    • MethodGET, POST, PUT, PATCH, or DELETE
    • Path — relative to your API prefix, e.g. xpress/trips → served at /api/xpress/trips
    • Status code — the HTTP status to respond with
    • Response body — any valid JSON, edited in a syntax-highlighted editor with a Format button
  3. Save. The endpoint is live immediately at the path you configured.

Requesting a method/path combination that hasn't been defined returns a 404:

Because mocks are served from whatever path you choose, frontend code can call the real, future API path from day one — no find-and-replace needed once the backend actually implements it.

Request validation

Any mock endpoint can also validate the incoming request before returning its response — useful for testing how your frontend handles a real 422, not just the happy path.

In the panel form, fill in Validation rules as a JSON object of field → Laravel validation rule string:

Leave it as {} to skip validation entirely (the default). When rules are set:

The 422 is built directly in the package's controller rather than thrown as an exception, so it's returned consistently regardless of how the host application customizes its own exception handling.

Configuration

No configuration is required to get started. To customize prefixes, middleware, or storage location, publish the config file:

This creates config/mock-api.php:

Key Env variable Default Description
enabled MOCK_API_ENABLED true Set to false to disable the package entirely (e.g. in production) without uninstalling it.
api_prefix MOCK_API_PREFIX api Prefix mock endpoints are served under.
panel_prefix MOCK_API_PANEL_PREFIX mock-panel Prefix the management panel is served under.
api_middleware ['api'] Middleware applied to the mock endpoint route group.
panel_middleware ['web'] Middleware applied to the panel route group. The panel ships with no authentication — add your own via this array if it needs protecting.
storage_path storage_path('app/mock-api/responses.json') Where the JSON manifest of mock responses is stored.
default_response ['success' => true, 'message' => 'Mockup Response', 'data' => null] Starting template pre-filled into a new endpoint's response body in the panel. Just a convenience default — each endpoint's response is still freely editable and can deviate from this shape entirely.
default_error_response ['success' => false, 'message' => null, 'data' => null] Base envelope for built-in error responses (mock not found, validation failure). message is always overwritten per error at request time; add extra keys here if your app's errors carry more than success/message/data.

Most of the time, setting the two env variables is enough — publishing the config file is only needed if you want to change middleware or storage location.

How it avoids colliding with your real routes

The catch-all mock route (ANY /api/{path}) registers itself after every other service provider has booted, so any route your application defines explicitly — /api/user, /api/xpress/ping, etc. — always takes priority. The mock route only ever handles requests that don't match anything else in your app.

Disabling in production

Set in your .env:

This skips route registration entirely — no mock endpoints and no panel.

License

MIT.


All versions of laravel-mock-api with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/routing Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/validation Version ^10.0|^11.0|^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 saimain/laravel-mock-api contains the following files

Loading the files please wait ...