Automatically copy Bootstrap and Bootstrap Icons assets to your CakePHP webroot/ directory when packages are installed or updated via Composer.
- ✨ Automatic copying of Bootstrap CSS and JS files
- ✨ Automatic copying of Bootstrap Icons CSS and fonts
- 🚀 Works with Composer package install/update hooks
- 🛠️ Manual CLI command for on-demand copying
- ✅ Fully compatible with CakePHP 4.x and 5.x
- 🔧 Customizable configuration and paths
- 📝 Comprehensive logging via Composer IO interface
Install the package via Composer:
composer require arthusantiago/bootstrap-for-cakephpThen ensure you have Bootstrap installed:
composer require twbs/bootstrap twbs/bootstrap-iconsThis package automatically detects when Bootstrap or Bootstrap Icons are installed or updated via Composer, and copies the necessary files to your CakePHP webroot/ directory:
- Bootstrap CSS/JS →
webroot/css/andwebroot/js/ - Bootstrap Icons →
webroot/css/andwebroot/css/fonts/
Once installed, the package automatically copies assets whenever you:
composer install
composer update
composer require twbs/bootstrap
composer update twbs/bootstrapIf you need to manually copy assets, use the CLI command:
# Copy all supported packages automatically
composer copy-bootstrap-assets
# Or copy specific package assets
composer copy-bootstrap-assets twbs/bootstrap twbs/bootstrap-icons
# Or copy each one individually
composer copy-bootstrap-assets twbs/bootstrap
composer copy-bootstrap-assets twbs/bootstrap-iconsExtend the AssetsConfig class to customize where assets are copied:
<?php
// config/AssetsConfig.php
namespace App\Config;
use ArthuSantiago\BootstrapForCakePHP\AssetsConfig;
class MyAssetsConfig extends AssetsConfig
{
protected static string $webrootPath = 'custom_webroot';
// Override package configuration
protected static array $packages = [
// ... custom configuration
];
}Then register your custom config in composer.json:
{
"scripts": {
"post-install-cmd": [
"ArthuSantiago\\BootstrapForCakePHP\\BootstrapAssets::setupAssets"
]
}
}Extend BootstrapAssets to implement custom logic:
<?php
namespace App\Tools;
use ArthuSantiago\BootstrapForCakePHP\BootstrapAssets;
use Composer\Script\Event;
class CustomBootstrapAssets extends BootstrapAssets
{
public static function setupAssets(Event $event): void
{
parent::setupAssets($event);
// Add custom logic here
// e.g., compile SCSS, minify files, etc.
}
}First, install development dependencies:
composer installThen run the test suite:
# Run all tests
composer test
# Or run directly with PHPUnit
vendor/bin/phpunit
# List all available tests
vendor/bin/phpunit --list-tests
# Run specific test file
vendor/bin/phpunit tests/TestCase/FileOperationsTest.php
# Run specific test method
vendor/bin/phpunit --filter testCopyFileShouldCopyFileSuccessfully
# Run tests from specific testsuite
vendor/bin/phpunit --testsuite "Bootstrap Assets Test Suite"- PHP 8.1 or higher
- CakePHP 4.0 or higher
- Composer 2.0 or higher
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit issues and pull requests to improve this package.
If you encounter any issues, please open an issue on the GitHub repository.