PHPackages                             lichtner/laravel-mock-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. lichtner/laravel-mock-api

ActiveLibrary[API Development](/categories/api)

lichtner/laravel-mock-api
=========================

Easy to use, but the powerful micro library for mocking external API

0.8.3(2y ago)27257↓100%2[2 PRs](https://github.com/lichtner/laravel-mock-api/pulls)MITPHPPHP ^8.1

Since Apr 15Pushed 2y ago1 watchersCompare

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

READMEChangelog (10)Dependencies (13)Versions (13)Used By (0)

Laravel MockApi
===============

[](#laravel-mockapi)

*Laravel MockAPI is a powerful yet lightweight library designed for mocking external APIs and web services.*

[![Latest Version on Packagist](https://camo.githubusercontent.com/b3d600633f29df655334c8b7bbbec22f4e85d02d512c584be89d95483a2d86f2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c696368746e65722f6c61726176656c2d6d6f636b2d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lichtner/laravel-mock-api)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ffa5f1ae86fb9a76dc1726c28a3754d6acd1c2d2ab03bb9d477b0944c1911607/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c696368746e65722f6c61726176656c2d6d6f636b2d6170692f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/lichtner/laravel-mock-api/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/9b71401afd9db4eb752c1878e7e2531175131d7ff6e4ea346f786d8f565a6df5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c696368746e65722f6c61726176656c2d6d6f636b2d6170692f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/lichtner/laravel-mock-api/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/8493d9afc140d94e2eed1f5545a0e33229c3504d084b7d10c1c5bf7bd0ae73aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c696368746e65722f6c61726176656c2d6d6f636b2d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lichtner/laravel-mock-api)

Why?
----

[](#why)

Are you using external APIs and web services during development that are also undergoing development? Are they unstable, slow, occasionally returning incorrect results, or unexpectedly unavailable? Are they causing you headaches? Me too! That was the reason why I created MockApi.

After installation and setup, MockApi will save all requests from your external web services in the background, and when they are unavailable, return them just like real APIs.

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

[](#installation)

```
composer require lichtner/laravel-mock-api
```

Now you can publish config file and run the migrations with:

```
php artisan mock-api:install
```

Setup
-----

[](#setup)

### Mocking GET request

[](#mocking-get-request)

Make a simple class that wrap all your `Http::get()` requests e.g.:

`app/HttpMock.php`

```
