Skip to content

Latest commit

 

History

History
133 lines (102 loc) · 5.44 KB

File metadata and controls

133 lines (102 loc) · 5.44 KB

GitHub User Viewer using PHP Multi-cURL

CI Build Status PHP Version PHPUnit Tests Code Style License

A high-performance, aesthetically pleasing PHP web application that queries the GitHub REST API concurrently to retrieve and compare user profile information. The project demonstrates how PHP Multi-cURL dramatically improves response times compared to traditional sequential HTTP requests.

The codebase is structured following modern Object-Oriented Programming (OOP) patterns with PSR-4 Autoloading via Composer.


⚡ Key Concepts

Sequential cURL (Single cURL)

In standard cURL executions, each HTTP request must finish before the next one starts (blocking I/O). The total execution time is the sum of all individual response times. $$\text{Total Time} = T_1 + T_2 + T_3 + \dots + T_n$$

Multi-cURL (Parallel cURL)

Multi-cURL executes multiple HTTP handles simultaneously (non-blocking I/O). The operations run in parallel, meaning the total execution time is limited only by the slowest single request. $$\text{Total Time} \approx \max(T_1, T_2, T_3, \dots, T_n)$$


📂 Project Structure

/
├── assets/
│   ├── screenshots/                # Screenshot assets
│   ├── script.js                   # Modals, user comparison, and AJAX handling
│   └── style.css                   # Premium dark glassmorphism styling
├── src/
│   ├── Client/
│   │   └── GitHubClient.php        # cURL initialization and response parser
│   ├── Exporter/
│   │   └── CsvExporter.php         # Standard CSV file streams
│   ├── Fetcher/
│   │   ├── ParallelFetcher.php     # Multi-cURL implementation
│   │   ├── ProfileFetcherInterface.php # Common contract for fetchers
│   │   └── SequentialFetcher.php   # Sequential fetching implementation
│   ├── Model/
│   │   └── UserProfile.php         # User profile model & representation
│   └── Util/
│       └── UsernameCleaner.php     # Sanitization, splitting, and de-duplication
├── composer.json                   # Composer definitions and PSR-4 settings
├── index.php                       # Front controller and dashboard layout
├── DEVELOPER.md                    # Deep-dive developer documentation
└── README.md                       # Project overview and instructions

🛠️ Requirements & Installation

  1. PHP 8.0+ installed on your system.
  2. cURL extension enabled in your PHP configuration (php.ini):
    extension=curl
  3. Composer installed globally to manage autoloading.
  4. Clone/download this repository and run the Composer installation inside the project directory:
    composer install

🚀 How to Run Locally

  1. Place the project folder inside your web server root directory (e.g. C:\laragon\www\concurrent-api-client-php).
  2. Run the PHP built-in server from the project directory:
    php -S localhost:8000
  3. Open your browser and navigate to http://localhost:8000.

🌟 Features Included

  • Sanitization & De-duplication: Cleans raw user input, parses lists split by commas/newlines, and removes duplicate requests.
  • Side-by-Side Comparison: Select any two fetched users to display a comprehensive comparison layout highlighting the winner in followers/repos.
  • Proxy Repository Viewer: Fetch and list a user's repositories on-demand using a secure local PHP API routing.
  • CSV Exporter: Instantly download a formatted report of fetched developer statistics.
  • Rate Limit Resilience: Integrates an optional input field for your GitHub Personal Access Token to prevent unauthenticated limit exhaustion (60 requests per hour vs 5000 requests per hour).
  • Modern OOP Architecture: Decoupled concerns, clean classes, dependency injection, interface contracts, and automated classloading.

📸 Application Screenshots

Home Page

GitHub Profile Fetcher - Home Page

Dashboard & Comparative Speed Chart

GitHub Profile Fetcher - Dashboard and Speed Comparison

Developer Comparison Modal

GitHub Profile Fetcher - Developer Comparison Modal

Repository Viewer Modal

GitHub Profile Fetcher - Repositories List Modal


🧪 Testing & Linting

This project implements strict verification using PHPUnit and PHP_CodeSniffer.

Running Unit Tests

A mock cURL testing technique is used so that the test suite does not trigger actual HTTP requests to the live GitHub API. This prevents API rate limit exhaustion and network delays during testing.

Run PHPUnit tests using the Composer shortcut:

composer test

Or directly:

vendor/bin/phpunit

Checking Coding Standards

To check for PSR-12 code style compliance, run:

composer lint

Or directly:

vendor/bin/phpcs --standard=PSR12 src/ tests/