I install many bundle in my Symfony2 project (I use Symfony 2.8). I follow doc to install these bundles with composer. But when I try to access page many ressource file are missing (error 404).
For example, with the Bundle TinymceBundle.
web/js/tinymce/tinymce.min.js
Is missing.
The bundle actually work but this file is missing.
This is my composer.json :
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/", "SymfonyStandard": "app/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.8.*",
"codeplex/phpexcel": "dev-master",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0,>=3.0.12",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"knplabs/knp-menu": "2.1.1",
"knplabs/knp-menu-bundle": "2.1.1",
"genemu/form-bundle": "2.2.*",
"swiftmailer/swiftmailer": "@stable",
"gregwar/captcha-bundle": "1.0.12",
"knplabs/knp-snappy-bundle": "dev-master",
"egulias/email-validator": "~1.2",
"friendsofsymfony/jsrouting-bundle": "^1.5",
"doctrine/doctrine-fixtures-bundle": "~2.2",
"stfalcon/tinymce-bundle": "1.0"
},
"require-dev": {
"sensio/generator-bundle": "~2.3"
},
"scripts": {
"post-root-package-install": [
"SymfonyStandard\\Composer::hookRootPackageInstall"
],
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
]
},
"config": {
"bin-dir": "bin",
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.6-dev"
}
}
}
I don't understand why the files isn't in the web/js, can you help me ?
Edit :
There is my stylesheet block :
{% block stylesheet %}
<link rel="stylesheet" href="{{ asset('css/DT_bootstrap.css') }}" />
<link rel="stylesheet" href="{{ asset('css/datatables.responsive.css') }}" />
{{ tinymce_init({
theme: {'simple':{'language': app.request.locale, 'height': 200 }},
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
autosave_ask_before_unload: false })
}}
{% endblock %}
And my linkscript block :
{% block linkscript %}
<script type="text/javascript" src="{{ asset('js/dataTable/datatables.responsive.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/tinymce/tinymce.min.js') }}"></script>
{% endblock %}
Thanks !
If bundle assets are missing (they are not created in assets folder) you maybe don't add this part of code to AppKernel:
<?php
// ...
public function registerBundles()
{
$bundles = array(
// ...
new Stfalcon\Bundle\TinymceBundle\StfalconTinymceBundle(),
);
}
Actually I have downloaded Symfony 2.8 and stfalcon/tinymce-bundle - you only need to add code to AppKernel, then run
php app/console assets:install web/
And then add to twig template this part:
{{ tinymce_init() }}
After that all files should be injected. This function will use this path to include tinemce:
web/bundles/stfalcontinymce/vendor/tinymce/tinymce.min.js
To sum up. If assets file not appeared after running console command, probably you didn't add bundle to AppKernel or maybe you are looking for this files in wrong place. In default, assets will be placed in
/web/bundles/*