A high-performance backend architecture analyzer built with PHP and JavaScript. It utilizes the cURL library to fetch remote source code and implements a custom SEO diagnostic engine using PHP DOMDocument.
- PHP cURL: Handles remote resource retrieval with custom headers and timeout management.
- DOMDocument Analysis: Implements technical SEO auditing for meta tags, content structure, and social graphs.
- JSON Serialization: Provides structured data output for frontend consumption and local storage.
- Stack Detection: Rule-based signature matching for identifying frameworks like React, Next.js, and WordPress.
- Clone the repository into your local server environment (e.g., XAMPP htdocs).
- Ensure the PHP cURL and OpenSSL extensions are enabled in your php.ini.
- Start your Apache server.
- Access the project via http://localhost/source-lens.
The system operates on a standard PHP configuration. Ensure the following server settings are optimized:
max_execution_time: 0 (Managed dynamically in fetch.php)allow_url_fopen: Onmemory_limit: 256M (Recommended for large DOM parsing)
/fetch.php
Request:
{
"url": "https://example.com"
}Response:
{
"source": "<!DOCTYPE html>...",
"url": "https://example.com",
"meta": {
"ip": "93.184.216.34",
"host": "example.com",
"status": 200,
"stack": ["Nginx", "PHP"],
"title": "Example Domain",
"server": "ECS (nyb/1D13)",
"load_time": 0.45,
"page_size": 1256,
"seo": {
"score": 85,
"categories": {
"technical": {"score": 30, "total": 40, "percent": 75},
"content": {"score": 40, "total": 50, "percent": 80}
},
"details": [
{
"category": "performance",
"label": "Load Speed",
"value": "0.45s",
"passed": true,
"score": 20,
"message": "Page loads quickly (under 2.5s)."
}
],
"summary": {
"passed": 8,
"failed": 2
}
}
}
}Errors:
- 200 (JSON Error):
{"error": "URL is required"}- Occurs when the payload is missing the target address. - 200 (JSON Error):
{"error": "Access to facebook.com is restricted."}- Occurs when targeting domains listed in the restricted array. - 200 (JSON Error):
{"error": "Network Error (Code 28): Timeout reached"}- Occurs when the target server fails to respond within 30 seconds. - 200 (JSON Error):
{"error": "Access denied (HTTP 403)"}- Occurs when the target website blocks the server's IP address.
| Technology | Purpose | Link |
|---|---|---|
| PHP 8.x | Server-side logic and cURL operations | php.net |
| Vanilla JavaScript | DOM manipulation and API orchestration | developer.mozilla.org |
| ApexCharts | Data visualization for SEO metrics | apexcharts.com |
| Highlight.js | Code syntax highlighting | highlightjs.org |
| Microlink API | Website screenshot generation | microlink.io |
To use SourceLens, navigate to the web interface and enter a valid URL in the search bar. The system will:
- Dispatch a POST request to the PHP backend.
- Fetch the raw HTML and server headers.
- Parse the DOM to calculate an SEO health score based on 10+ metrics.
- Render the source code with syntax highlighting and generate a live preview.
- Provide options to download the raw HTML or a structured JSON report.
- Fork the repository and create your feature branch. 🏗️
- Ensure your code adheres to standard PSR-12 formatting for PHP. 🧹
- Submit a pull request with a detailed description of your changes. 🚀
Developed by Precious Adedokun. 👨🎓
- LinkedIn: linkedin.com/in/yourusername
- Twitter: @yourusername
- Website: preciousadedokun.com.ng