Download the PHP package metalogico/laravel-mocka without Composer

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

Laravel Mocka โ˜•

Latest Version on Packagist

Laravel Mocka provides fake API responses to designated users while serving real data to everyone else. A drop-in replacement for Laravel's Http facade, perfect for app store submissions, demos, and testing without disrupting production traffic.

Why Mocka?

When your Laravel app calls external APIs (like DMS, MES, or any third-party service), you often need to provide mock responses for:

Features

Installation

You can install the package via composer:

Publish the config file:

Quick Start

1. Configure Mock Users

In your .env file:

2. Create Mock Files

Create mock files in resources/mocka/:

resources/mocka/api.mock.php

3. Configure URL Mappings

In config/mocka.php:

4. Use MockaHttp in Your Services

Replace Laravel's Http facade with MockaHttp:

Advanced Features

Response Types: Static, Dynamic, or Hybrid

Mocka supports three approaches for mock responses:

Static Responses

Perfect for app store reviews and basic demos:

Dynamic Responses

For complex testing with varying data:

Hybrid Responses

You can even mix static and dynamic data as needed:

Advanced URL Matching

Configure sophisticated URL matching patterns:

Error Simulation

Simulate API errors by defining error configurations in your mappings:

Define error responses in your mock files:

Rate Limiting Simulation

Add delays to simulate slow APIs:

Jobs and Artisan (Force Activation)

When running inside queued Jobs or Artisan commands (where there is no web request/user), you can explicitly enable Mocka per request using options:

Notes:

Artisan Commands

List Mock Mappings

List all configured mappings and whether they correctly resolve to a mock file/key. The output uses a compact, two-line layout per mapping:

Per mapping you will see two rows:

Configuration

The configuration file config/mocka.php supports these options:

How It Works

  1. Activation Check: If enabled and allowed by environment/host, Mocka checks activation triggers in order: user allowlist, withOptions(['mocka' => true]), or X-Mocka header
  2. URL Matching: If the user should be mocked, it matches the request URL against the configured mappings
  3. Mock Loading: Loads the appropriate mock file and extracts the response using dot notation
  4. Template Processing: Processes any template variables (faker, time functions, etc.)
  5. Response Simulation: Returns the mock response with optional delays or errors
  6. Logging: Logs whether the request was mocked or passed through

Testing

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.


Made with โ˜• in Italy


All versions of laravel-mocka with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
laravel/framework Version ^9.0|^10.0|^11.0|^12.0
laravel/prompts Version ^0.3.6
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 metalogico/laravel-mocka contains the following files

Loading the files please wait ...