I've got a problem here, which I have a feeling got a simple and clean solution which I haven't found yet... My Cake-PHP-Application looks like this:
Cake-PHP and the external file I want to use are installed inside the vendors-folder. In vendors I have a package for twitter bootstrap, which has a css- and a js-file I want to include inside my view, but it ain't accessable, since those file don't remain inside the webroot-Folder of my Cake-PHP project. Now my question is - How do I make those both files accessable inside my Cake-PHP project, WITHOUT copying them to the webroot-folder? Using symlinks looks a bit like a dirty hack to me... There has to be a clean solution, since otherwise using Cake-PHP with Composer would make no sence. My composer.json looks like this:
{
"name": "MyProject",
"version": "0.0.0",
"require": {
"php": ">=5.5.11",
"cakephp/cakephp": "2.6.3",
"composer/installers": "*",
"twbs/bootstrap": "3.3.4",
"components/jquery": "2.1.3"
},
"extra" : {
"installer-paths":{
"plugins/{$name}":["type:cakephp-plugin"],
"app/webroot/bootstrap":["twbs/bootstrap"]
}
},
"config": {
"vendor-dir": "vendors"
}
Btw: composer ignores the given installpath for bootstrap, since the package has no type...
Installing CakePHP Go to the folder where wamp is located for windows users and in www/ folder, create a folder cakephp4/. For Linux users, create the folder var/www/html/ and then create folder cakephp4/. cakephp4/ is the folder where we are going to install CakePHP.
CakePHP uses Composer, a dependency management tool, as the officially supported method for installation. Installing Composer on Linux and macOS.
Using tws/bootstrap
will require an additional step for the installation of these assets. This is often done by symlinking or copying.
For instance, when adding Bootstrap to Symfony2 you would require
"require" : {
"mopa/bootstrap-bundle": "dev-master",
"twbs/bootstrap": "dev-master",
},
"scripts": {
"post-install-cmd": [
/* sensio commands **/
"Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"
],
"post-update-cmd": [
/* sensio commands **/
"Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"
]
},
One package is the asset itselfs, the other packages provides the integration and "postInstall" handler for the asset.
For Cake you would have to find the package doing the installation job for tws/boostrap
- maybe such a package is around in the Cake community.
But i would suggest using something easier, which works out of the box:
{
"require": {
"slywalker/boost_cake": "*"
}
}
And then use enable CakePlugin::load('BoostCake');
and add the helpers you need.
As @ndm pointed out: you could also decide to work with Composer "bridges" to other asset managers (indirect). One of them is https://github.com/francoispluchino/composer-asset-plugin
Or you could work with these asset managers, like bower, npm directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With