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

ActiveMagento2-module[API Development](/categories/api)

exequiellares/mock-api
======================

Magento 2 module to add mock api feature

1.1.0(3y ago)18GPL-3.0-or-laterPHPPHP ~7.4.0||~8.1.0

Since Apr 20Pushed 3y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Magento 2 Mock API
==================

[](#magento-2-mock-api)

This module will add a frontend controller into the current Magento store that will simulate an API.

This is useful to test new features that requires external API connections.

The module adds two public controllers:

- POST {domain}/mockapi/
- GET {domain}/mockapi/

The controller response should return JSON data that will be configurable.

The controller request should receive a Bearer token to validate the request. The token is configurable.

The module allow to define a set of fields that the body must have in order to validate request and simulate Bad Request responses.

Allow to log into custom file received request.

Install
-------

[](#install)

```
composer require exequiellares/magento2-mock-api
php bin/magento module:enable ExequielLares_MockApi
php bin/magento setup:upgrade

```

Settings
--------

[](#settings)

The module configuration is available at:

Stores &gt; Configuration &gt; Advanced &gt; Developer &gt; Mock API

### Options

[](#options)

- **Enabled**: enable or disable the module
- **Enable Log**: enable or disable the log of received requests
- **Validate Token**: enable or disable the validation of the token. If disabled, the token will be ignored.
- **Token**: Token to validate the request. If empty, the token will be ignored.
- **GET display request on response**: If enabled, the GET request will return the request body on the response.
- **POST display request on response**: If enabled, the POST request will return the request body on the response.
- **Validate Request Fields**: If enabled, the request body will be validated against the fields defined on the next option.
- **Fields to Validate**: List of fields to validate. The fields must be separated by a comma. Example: id,currency,discount,total,shipping,name,address,city,state,postcode,country,amount,method
- **Force Error Response**: If enabled, the response will be an error response.
- **Error Message**: Error message to return on the response. If empty, the default message will be used.
- **Success Message**: Success message to return on the response. If empty, the default message will be used.

Example usage:
--------------

[](#example-usage)

### GET request

[](#get-request)

```
curl --location --request GET 'https://local.magento2.com/mockapi/?XDEBUG_SESSION_START=PHPSTORM' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer tokenFalso1234' \
--header 'Cookie: PHPSESSID=c357851ccf74ce451fbd5457b81eb636; XDEBUG_SESSION=PHPSTORM; mage-messages=%5B%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%5D; private_content_version=5918e325802932538802aac4b4c892eb' \
--data '{
    "id": "000000001",
    "currency": "USD",
    "discount": "0.0000",
    "total": "36.3900",
    "shipping": {
        "name": "Veronica Costello",
        "address": "6146 Honey Bluff Parkway",
        "city": "Calder",
        "state": "Michigan",
        "postcode": "49628-7978",
        "country": "US",
        "amount": "5.0000",
        "method": "Flat Rate - Fixed",
    }
}'

```

### POST request

[](#post-request)

```
curl --location 'https://local.magento2.com/mock_erp_api?XDEBUG_SESSION_START=PHPSTORM' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer tokenFalso1234' \
--header 'Cookie: PHPSESSID=c357851ccf74ce451fbd5457b81eb636; XDEBUG_SESSION=PHPSTORM; mage-messages=%5B%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%2C%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%5D; private_content_version=cea3ca278c04ca29a7d9ab339a2b572c' \
--data '{
    "id": "000000001",
    "currency": "USD",
    "discount": "0.0000",
    "total": "36.3900",
    "shipping": {
        "name": "Veronica Costello",
        "address": "6146 Honey Bluff Parkway",
        "city": "Calder",
        "state": "Michigan",
        "postcode": "49628-7978",
        "country": "US",
        "amount": "5.0000",
        "method": "Flat Rate - Fixed",
    }
}'

```

Logger
------

[](#logger)

Received request are logged into: var/log/mock\_api.log

Next features
-------------

[](#next-features)

- Allow to configure body response on GET request
- Allow to configure body response on POST request

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~14 days

Total

2

Last Release

1101d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/77435327f88d8c5b9df878734d32a52ef939b8725df00a547e088ad8651d72d7?d=identicon)[exequiellares](/maintainers/exequiellares)

---

Top Contributors

[![exequiellares](https://avatars.githubusercontent.com/u/16387203?v=4)](https://github.com/exequiellares "exequiellares (12 commits)")

### Embed Badge

![Health badge](/badges/exequiellares-mock-api/health.svg)

```
[![Health](https://phpackages.com/badges/exequiellares-mock-api/health.svg)](https://phpackages.com/packages/exequiellares-mock-api)
```

###  Alternatives

[smile/elasticsuite

Magento 2 merchandising and search engine built on ElasticSearch

8044.5M33](/packages/smile-elasticsuite)[mollie/magento2

Mollie Payment Module for Magento 2

1121.6M10](/packages/mollie-magento2)[graycore/magento2-cors

A Magento 2 module that enables CORS on the GraphQL and REST Apis

99516.1k](/packages/graycore-magento2-cors)[elgentos/module-prismicio

Magento 2 - Prismic.io integration

39112.0k3](/packages/elgentos-module-prismicio)[zepgram/module-rest

Technical module to industrialize API REST call with dependency injection pattern using Guzzle library

1326.2k](/packages/zepgram-module-rest)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
