π οΈ Path2URL is a powerful PHP library designed to automatically convert relative file paths to absolute URLs in HTML, CSS, and JavaScript files. Perfect for migrating websites, setting up CDNs, or managing content across different environments.
β° Last Updated: 2024-11-12 14:53:36 UTC
π Key Features:
- π Converts relative paths to absolute URLs
- π Supports HTML, CSS, and JavaScript files
- πΎ Automatic backup creation before modifications
- π Comprehensive logging system
- βοΈ Configurable file extensions
- π Type-safe with PHP 7.4+ features
π¦ Install the package via Composer:
composer require abdessattar23/path2urluse Path2URL\Path2URL;
// Initialize the converter
$converter = new Path2URL(
'/path/to/your/files',
'https://your-domain.com'
);
// Process all files
$stats = $converter->process();<!-- Before -->
<img src="./images/logo.png">
<a href="../docs/guide.pdf">
<!-- After -->
<img src="https://your-domain.com/images/logo.png">
<a href="https://your-domain.com/docs/guide.pdf">/* Before */
background-image: url('./images/bg.jpg');
background: url('../assets/pattern.png');
/* After */
background-image: url('https://your-domain.com/images/bg.jpg');
background: url('https://your-domain.com/assets/pattern.png');// Custom configuration
$converter = new Path2URL(
'/path/to/your/files',
'https://your-domain.com',
['html', 'css', 'js', 'xml'], // Custom file extensions
'custom_log.log' // Custom log file
);[2024-11-12 13:46:07] [INFO] Starting URL conversion process
[2024-11-12 13:46:07] [INFO] Processing file: /path/to/file.html
[2024-11-12 13:46:07] [INFO] Created backup: file.html.1731417583.bak
[2024-11-12 13:46:07] [INFO] Successfully processed file
- π» PHP 7.4 or higher
- π¦ Composer for dependency management
Run the test suite:
composer testπ‘οΈ Found a security issue? Please email abdessattar23 instead of using the issue tracker.
Contributions are welcome! Please see CONTRIBUTING for details.
βοΈ The MIT License (MIT). Please see License File for more information.
- π₯οΈ CLI interface implementation
- π Additional file type support
- βοΈ Custom URL transformation rules
- π Framework integrations
- β‘ Real-time processing option
- π¨βπ» Author: abdessattar23
- π All Contributors
If you found this package helpful, please consider:
- β Starring the repository
- π Reporting issues
- π€ Contributing to the code
- β Buy me a coffee
π₯ Created and maintained by abdessattar23
If this package helps your project, please consider giving it a β
