PHPackages                             proklung/request-log-bundle - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. proklung/request-log-bundle

ActiveSymfony-bundle[Logging &amp; Monitoring](/categories/logging)

proklung/request-log-bundle
===========================

Бандл для создания и использования моков Response.

1.0.0(5y ago)117MITPHPPHP &gt;=7.1

Since May 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ProklUng/request.log.bundle)[ Packagist](https://packagist.org/packages/proklung/request-log-bundle)[ RSS](/packages/proklung-request-log-bundle/feed)WikiDiscussions master Synced 1w ago

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

Бандл для создания и использования моков Response
=================================================

[](#бандл-для-создания-и-использования-моков-response)

Форк [пакета](https://github.com/mRoca/MrocaRequestLogBundle). Доработан под личные нужды, плюс добавил некоторые экспериментальные битриксовые наработки (получилось не стабильно).

Зачем?
------

[](#зачем)

Удобно генерировать фикстуры для функциональных тестов из ответов внешнего API.

Основное
--------

[](#основное)

1. Добавляешь заголовок `x-generate-response-mock` к запросу - получаешь мок в виде файла. Если мок уже существует, то отдаются данные из него

***Известные ограничения***

Если GET запрос очень длинный - превышает 255 символов, - то облом, сохранить мок не удается.

Битриксовые дела
----------------

[](#битриксовые-дела)

Если бандл грузится не из под Битрикса, то соответствующие сервисы удаляются из контейнера.

Идея - создавать моки по url, использующим нативные битриксовые средства (или даже статические страницы).

В конфигурации бандла (файл `/local/config/packages/request_log.yaml`) в секции `bitrix_uri_list` указываются regex паттерны страниц, подвергающихся обработке.

Установка
---------

[](#установка)

```
composer require proklung/request-log-bundle
```

Оригинальная документация
=========================

[](#оригинальная-документация)

Description
-----------

[](#description)

This bundle allows to log HTTP requests and associated responses as json files. This generated json files can be used as API mock in order to test a front app without running the api.

How it works ?
--------------

[](#how-it-works-)

After each request (`Kernel::TERMINATE` event) containing the `x-generate-response-mock` header, a json file is created containing the request and the response.

**Examples :**

> GET /categories

`app/log/mocks/categories/GET__.json`

```
{
    "request": {
        "uri": "/categories",
        "method": "GET",
        "parameters": [],
        "content": ""
    },
    "response": {
        "statusCode": 200,
        "contentType": "application/json",
        "content": {
            "@context": "/contexts/Category",
            "@id": "/categories",
            "hydra:member": [
                {"name": "foo"},
                {"name": "bar"}
            ]
        }
    }
}
```

> PUT /categories/1 {"foo": "bar"}

`app/log/mocks/categories/PUT__1-a5e74.json`

```
{
    "request": {
        "uri": "/categories/1",
        "method": "PUT",
        "parameters": [],
        "content": {
            "foo": "bar"
        }
    },
    "response": {
        "statusCode": 204,
        "contentType": "application/json",
        "content": ""
    }
}
```

**File naming strategy**

All files are created with the following convention :

`uri/METHOD__segments{--sorted-query=string&others}{__}{__}.json`

*Examples* :

URLFilenameGET /GET\_\_.jsonGET /categoriescategories/GET\_\_.jsonGET /categories/1categories/GET\_\_1.jsonGET /categories?search\[category\]\[\]=foocategories/GET\_\_--search%5Bcategory%5D%5B%5D=foo.jsonGET /categories?order\[foo\]=asc&amp;order\[bar\]=desccategories/GET\_\_--order%5Bbar%5D=desc&amp;order%5Bfoo%5D=asc.jsonGET /categories?parent=/my/iricategories/GET\_\_--parent=%2Fmy%2Firi.jsonPOST /categories PARAMS: foo1=bar1; foo2=bar2categories/POST\_\_\_\_3e038.jsonPOST /categories CONTENT: {"foo1":"bar1", "foo2":"bar2"}categories/POST\_\_\_\_3e038.jsonPUT /categories/1 CONTENT: {"foo2":"bar2", "foo1":"bar1"}categories/POST\_\_1\_\_3e038.json```
The filenames query strings can be hashed by setting the `hash_query_params` option to `true`.
For example, `categories/GET__--order[bar]=desc&order[foo]=asc.json` will be `categories/GET__--b0324.json`

The filenames query strings with non-asssocitive arrays are not indexed by default : `?foo[]=bar`.
You can use the indexed format by setting the `use_indexed_associative_array` option to `true` : `?foo[0]=bar`.

```

*If necessary*, configure the bundle to your needs (example with default values):

```
# app/config/config_dev.yml

request_log:
    mocks_dir: %kernel.logs_dir%/mocks/
    hash_query_params: false
    use_indexed_associative_array: false
    # Битриксовые URL (нестабильный функционал)
    bitrix_uri_list:
     # - '/^\/clubs\/$/'
     #  - '/^\/about\/$/'
     # - '/^\/xxx\/$/'
```

**If your are using the NelmioCorsBundle** or another CORS protection, you must add the header in the allowed ones :

```
nelmio_cors:
    defaults:
        allow_headers: ['x-generate-response-mock']
```

Usage
-----

[](#usage)

The request &amp; response logger is not always activated. To log a request, add the `x-generate-response-mock` header into your request :

```
GET /categories HTTP/1.1
Host: api.my.domain
x-generate-response-mock: true

```

Commands
--------

[](#commands)

Some useful commands are available to manager your mocks :

### Clear all mocks

[](#clear-all-mocks)

```
app/console mroca:request-log:clear
```

### Save mocks in a target directory

[](#save-mocks-in-a-target-directory)

```
app/console mroca:request-log:dump /tmp/mocksdirtarget
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Unknown

Total

1

Last Release

1841d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9210c86ee6734e537eaf22c0f2fe7a965451e340e39e1aae2b74013f24c2660d?d=identicon)[gedovan](/maintainers/gedovan)

---

Top Contributors

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

---

Tags

bitrixbitrix-symfonyphp7symfony-bundle

### Embed Badge

![Health badge](/badges/proklung-request-log-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/proklung-request-log-bundle/health.svg)](https://phpackages.com/packages/proklung-request-log-bundle)
```

###  Alternatives

[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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