Pancake Project

Pancake is a versatile and easy-to-use toolkit for PHP projects designed to simplify common tasks such as session management, HTTP requests, and configuration parsing. It provides developers with a clean, well-organized API to improve productivity and code quality.

Pancake logo

This project is proudly maintained by @guibranco GitHub followers.

Source code is available on GitHub: Pancake Repository GitHub stars


Table of Contents


About Pancake

Pancake is a lightweight PHP toolkit focused on streamlining everyday project requirements. It includes several modules that handle common operations such as session management, HTTP request handling, and parsing TOML configuration files. Pancake's goal is to make these operations more accessible and intuitive, allowing developers to concentrate on building features rather than boilerplate code.

Whether working on small projects or large-scale applications, Pancake can help you maintain clean, readable, and maintainable code.


Key Features

Pancake offers a variety of features to enhance your PHP projects:

  • Color: Utility for managing colors based on text.
  • Database: Interface for managing database connections and queries.
  • GUID v4: Generate unique GUIDs for your data entities.
  • Health Checks: Monitor the health status of your applications and services.
  • HTTP Requests: Easily send and manage HTTP requests, supporting multiple methods such as GET, POST, PUT, and DELETE.
  • IP Utils: Utility functions for validating, checking ranges, and converting IP addresses in both IPv4 and IPv6 formats.
  • Logger: Robust logging capabilities to track application events and errors.
  • Memory Cache: Implement caching strategies to improve application performance.
  • One Signal: Integrate One Signal for push notifications in your applications.
  • Session Manager: Simplify PHP session handling with methods for setting, getting, and managing session data, including flash messages.
  • ShieldsIo: Create custom badges for your projects using Shields.io.

For more detailed documentation on each feature, check out the links above.


Project Status

Pancake is actively maintained, and new features or bug fixes are added frequently. Below is the current status of the project:

Build Status Last Commit Coverage Code Smells LoC
CI GitHub last commit Coverage Code Smells Lines of Code
  • Open Issues: GitHub issues

Getting Started

To get started with Pancake in your project, follow these steps:

Installation

Install Pancake via Composer:

composer require guibranco/pancake

Basic Usage Example

<?php

use GuiBranco\Pancake\SessionManager;
use GuiBranco\Pancake\Request;

// Start session
SessionManager::start();
SessionManager::set('user', 'john_doe');

// HTTP Request
$response = (new Request())->get('https://api.example.com/data');
echo $response->getBody();

For more detailed guides on specific features, please see the Basic Usage Documentation.


Testing

Setup for Testing

To prepare for testing, please ensure you have PHP, Composer, PHPUnit, and Xdebug installed on your system. Also, install VSCode and the Gutter Coverage extension to view code coverage directly in your editor.

Enabling Xdebug

  1. Install Xdebug if it's not already installed: bash pecl install xdebug

  2. Enable Xdebug: Open your PHP configuration file (php.ini) and add or modify the following lines: ini [xdebug] zend_extension=xdebug.so xdebug.mode=coverage xdebug.start_with_request=yes

  3. Verify Xdebug Installation: Restart your PHP environment and run: bash php -v Confirm that Xdebug is listed in the output.


Running Tests

Running Tests Without Coverage

To execute tests without coverage reports, run:

./vendor/bin/phpunit --configuration tests/phpunit.xml

Running Tests With Coverage

To generate a coverage report with Xdebug enabled, use:

XDEBUG_MODE=coverage ./vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover test-reports/cov.xml

The coverage report will be saved in test-reports/cov.xml. You can use this file with VSCode to visualize coverage.


Viewing Code Coverage in VSCode

  1. Install the Gutter Coverage extension in VSCode.
  2. In the Gutter Coverage settings, configure it to point to test-reports/cov.xml.
  3. After running tests with coverage, open your source files to see coverage indicators for each line.

Debugging with Xdebug

  1. Set breakpoints in VSCode.
  2. Open the Run and Debug panel in VSCode, select Listen for Xdebug, or set up a new configuration if needed.
  3. Run your tests from the command line or start a debugging session in VSCode.

Contributing

We welcome contributions! If you'd like to contribute to Pancake, please check the contributing guide and browse the open issues.


License

This project is licensed under the MIT License - see the LICENSE file for details.