acseo / profiler-cli
Symfony CLI command for interacting with the Symfony Profiler, displaying and exporting HTTP requests as curl commands.
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.4 || ^8.0
- symfony/console: ^5.0 || ^6.0
- symfony/http-kernel: ^5.0 || ^6.0
- symfony/profiler-pack: ^1.0
This package is auto-updated.
Last update: 2024-12-10 14:10:19 UTC
README
This Symfony bundle provides a CLI command that interacts with the Symfony Profiler. It allows users to display the details of profiler tokens, export curl
commands for HTTP requests, and interact with profiler data in an efficient and flexible way.
Features
- List recent profiler tokens with detailed information (IP, URL, HTTP method, etc.).
- Display the details of a specific token, including headers, request body, and the generated
curl
command. - Export the
curl
command for individual tokens or for all retrieved tokens. - Interact with an easy-to-use interactive menu, or use command-line options for direct access.
Requirements
- PHP 7.4 or higher
- Symfony 5.x or 6.x
- Symfony Profiler enabled
Installation
- Install the bundle via composer:
composer require acseo/profiler-cli
- Enable the bundle in your bundles.php:
return [ // Other bundles ACSEO\ProfilerCliBundle\ProfilerCliBundle::class => ['dev' => true], ];
- Ensure the Symfony Profiler is enabled in your environment by checking config/packages/dev/web_profiler.yaml:
web_profiler: toolbar: true intercept_redirects: false
Usage
List Profiler Tokens
By default, the command lists the most recent profiler tokens, displaying their token, IP address, HTTP method, URL, and request time.
php bin/console acseo:profiler-cli
You can filter the tokens by using the following options:
--ip
: Filter by IP address--url
: Filter by URL--method
: Filter by HTTP method (e.g.,GET
,POST
)--limit
: Specify the number of tokens to retrieve (default is10
)--start
: Specify a start date inY-m-d H:i:s
format--end
: Specify an end date inY-m-d H:i:s
format
Example:
php bin/console acseo:profiler-cli --limit=5 --method=POST
Display Token Details
You can directly display the details of a specific token by passing the --token
option:
php bin/console acseo:profiler-cli --token=abc123
This will display the HTTP request information, including headers, request body, and the generated curl
command.
Export curl Command
To export the curl
command for a specific token, use both the --token
and --export
options together:
php bin/console acseo:profiler-cli --token=abc123 --export
This will generate a file in the format curl_YmdHis-abc123.txt
containing the curl
command.
You can also export the curl
commands for all retrieved tokens:
php bin/console acseo:profiler-cli --export
Interactive Menu
When running the command without options, an interactive menu is displayed. You can navigate the menu using the following keys:
m: Redisplay the token list
d: Display the details of a specific token
e: Export the curl command for the selected token
q: Quit the program
Example Use Cases
- Automated Testing: Use the generated curl commands to replay HTTP requests and test API behavior.
- Debugging: Quickly fetch request headers and bodies for analysis.
- Profiling: Filter and analyze specific requests by IP, URL, or HTTP method.
Contributing
We welcome contributions! Please submit a pull request or open an issue for discussion. Make sure to follow the existing coding style and include unit tests where applicable.
License
This bundle is licensed under the MIT License. See the LICENSE file for details.