In a symfony2 project, I use assetic with less filter.
Everything is ok in prod environnement, the command assetic:dump generates corrects css files.
But when I render the page in dev envrionnement, my css files tell me that the less module could not be find.
It looks like that:
[exception] 500 | Internal Server Error | Assetic\Exception\FilterException
[message] An error occurred while running:
"/usr/bin/node" "/tmp/assetic_lessb45F2E"
Error Output:
module.js:340
throw err;
^
Error: Cannot find module "less"
My config.yml seems to be good
assetic:
debug: %kernel.debug%
use_controller: false
filters:
cssrewrite: ~
less:
node: /usr/bin/node
node_paths: /usr/local/lib/node_modules
apply_to: "\.less$"
My project is served by Apache runned by www-data user.
I tried to chmod 777 my node_modules folder just in case.
Your config does not respect the right hierarchy, and no need to specify .less extension, ir-s default config for less filter :
assetic:
debug: %kernel.debug%
use_controller: false
node: /usr/bin/node
node_paths: /usr/lib/node_modules
filters:
cssrewrite: ~
less: ~
Check /usr/bin path if node binary is in there (or linked), but maybe you should define this binary (looks like you locally installed node) :
node: /usr/local/bin/node
node_paths: /usr/LOCAL/lib/node_modules
Related
My assetic configuration is:
assetic:
debug: '%kernel.debug%'
use_controller: false
filters:
less:
node: /usr/local/bin/
node_paths: [/usr/local/lib/node_modules]
apply_to: '\.less$'
when I run command bin/console assetic:dump then I am getting below error:
[Assetic\Exception\FilterException]
An error occurred while running:
'/usr/local/bin/' '/tmp/assetic_lessgyMQtZ'
Error Output:
sh: 1: /usr/local/bin/: Permission denied
Attempts to use a sqlite file database in the app/cache/tests directory fail. This is determined by clearing the dev MySQl database and populating the test environment database via the console. Test database being populated was confirmed by an external Sqlite Manager. [Tests performed without the sqlite configuration pass.]
codeception.yml:
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
settings:
bootstrap: _bootstrap.php
colors: false
memory_limit: 1024M
extensions:
enabled:
- Codeception\Extension\RunFailed
modules:
config:
- Db:
dsn: 'sqlite:./app/cache/test/test.sqlite'
user: ''
password: ''
dump: tests/_data/test.sql
populate: true
cleanup: false
reconnect: true
Edit:
In an Ubuntu VM, adding the Symfony2 configuration to acceptance.yml allows for partial success - the test uses the Sqlite db but does not rewrite from the specified dump (test.sql). In Windows adding the Symfony configuration makes no difference.
acceptance.yml:
class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: http://vol
- \Helper\Acceptance
# adding these lines enables Ubuntu to use sqlite db
- Symfony2:
app_path: ./app
environment: test
You haven't enabled Db module in acceptance.yml
modules:
enabled:
- Db
- PhpBrowser:
url: http://vol
- \Helper\Acceptance
Also don't add PhpBrowser and Symfony2 at the same time,
only one can be used.
I need use mysql functions in qb such as DATE(), NOW(), FROM_UNIXTIME() etc. I reading this topic How to install Doctrine Extensions in a Symfony2 project. I did it:
composer require "beberlei/DoctrineExtensions":"dev-master"
all became normal:
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing beberlei/doctrineextensions (dev-master 5e4ec9c)
Cloning 5e4ec9c3ec3434151e1c73144b4ab87ae30aefbc
etc...
Đ•hen I did it:
doctrine:
orm:
auto_generate_proxy_classes: %kernel.debug%
entity_managers:
default:
auto_mapping: true
dql:
datetime_functions:
MONTH: DoctrineExtensions\Query\Mysql\Month
YEAR: DoctrineExtensions\Query\Mysql\Year
BUT! Symfony return this exception for me:
FileLoaderLoadException: Cannot import resource "/home/domain/www/domain.com/app/config/config.yml" from "/home/domain/www/domain.com/app/config/config_dev.yml". (A YAML file cannot contain tabs as indentation at line 106 (near " dql:").)
Sorry for my english, but in russia internet segment no normal specialists for Symfony2 framework. I hope for your help, my friends!
From your error:
A YAML file cannot contain tabs as indentation at line 106 (near " dql:")
You have tabs in this file:
doctrine:
orm:
auto_generate_proxy_classes: %kernel.debug%
entity_managers:
default:
auto_mapping: true
dql:
datetime_functions:
MONTH: DoctrineExtensions\Query\Mysql\Month
YEAR: DoctrineExtensions\Query\Mysql\Year
Instead tabs create spaces.
I have a project where I keep my uploaded images in src/My/Bundle/Resources/uploads/images/full and use the twig filter imagine_filter to dynamically create thumbnails.
On my local machine it works flawlessly and so does on my server, but there only under the dev environment. When I delete the previously created thumbnails (leaving only the full directory), clear the prod cache and load any web page, the images are not created, their url always remains under media/cache, and the logger gives me the request.ERROR:
"No route found for "GET /uploads/images/avatar/354026c94b773b77ca945b4a6323e15c84102f6b.jpg"" at /<path>/app/cache/prod/classes.php line 1964 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException: No route found for \"GET /uploads/images/avatar/354026c94b773b77ca945b4a6323e15c84102f6b.jpg\" at /<path>/app/cache/prod/classes.php:1964, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException: at /<path>/app/cache/prod/appProdUrlMatcher.php:1816
Some additional infos:
I have symlinked src/My/Bundle/Resources/uploads to web/uploads
my config is (thumbnail_min is a custom filter):
liip_imagine:
loaders:
default:
filesystem:
data_root: %kernel.root_dir%/../web/uploads/images/full
resolvers:
default:
web_path:
web_root: %kernel.root_dir%/../web
cache_prefix: /uploads/images
cache: default
filter_sets:
avatar:
quality: 90
filters:
thumbnail_min: { size: 50, mode: inset }
....
full:
quality: 100
permissions are always at least group rw (that's what is needed on the server)
Just experienced a similar problem on my local machine, however still in dev environment.
For me, I was missing group writable permission on the default media/cache folder, which stayed empty after a liip:imagine:cache:remove and page reload. Thus images were linking to empty folder.
To fix, I first made sure that Group was set to Apache's _www (mac) / www-data (linux), e.g.
sudo chgrp -R www-data web/media/cache
Then made sure the folder was set to readable, writable and executable, e.g.
sudo chmod -R g+rwx web/media/cache
Hope this helps...
I installed a Symfony2 extension for Behat Mink from here
When I run test, an error occurs
[ReflectionException] Class AppKernel does not exist.
What am I doing wrong?
behat.yml
default:
extensions:
Behat\MinkExtension\Extension:
base_url: http://localhost/behat
goutte: ~
selenium2: ~
Behat\Symfony2Extension\Extension: ~
First run these commands to install the dependencies:
composer require behat/behat
composer require behat/symfony2-extension
composer require behat/mink
composer require behat/mink-browserkit-driver
composer require behat/mink-extension
composer require behat/mink-goutte-driver
composer require behat/mink-selenium2-driver
composer require emuse/behat-html-formatter
composer require coduo/php-matcher
Now say your symfony applcation you want to host as localhost.behat, then add the vhost configuration to httpd_vhost.conf:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/behat/web"
ServerName lochost.behat
DirectoryIndex app_dev.php
<Directory "C:/xampp/htdocs/behat/web">
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Now your behat.yml file should be at app/config/behat.yml with belo content :
default:
formatters:
html:
output_path: web/behat
extensions:
Behat\Symfony2Extension: ~
# Irs\BehatPopupExtension\Extension: ~
Behat\MinkExtension:
base_url: http://lochost.behat/app_dev.php/
javascript_session: selenium2
sessions:
symfony2:
symfony2: ~
selenium2:
selenium2:
browser: chrome
emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
name: html
renderer: Twig,Behat2
file_name: index
print_args: true
print_outp: true
loop_break: true
suites:
api:
type: symfony_bundle
bundle: NameSpaceYourBundle
#mink_session: symfony2
mink_session: selenium2
contexts:
- NameSpace\YourBundle\Features\Context\FeatureContext:
baseUrl: http://lochost.behat/app_dev.php/
screenCapturePath: web/behat
# Add "-p firefox" parameter to behat command to run tests with Firefox browser
firefox:
extensions:
Behat\MinkExtension\Extension:
browser_name: firefox
# Add "-p chrome" parameter to behat command to run tests with Chrome browser
chrome:
extensions:
#Behat\MinkExtension\Extension:
Behat\MinkExtension:
browser_name: chrome
# Add "-p safari" parameter to behat command to run tests with Safari browser
safari:
extensions:
Behat\MinkExtension\Extension:
browser_name: safari
All you go, now add your feature and context file at namespace : NameSpace\YourBundle\Features\Context\FeatureContext
and run the below commands from command prompt/git bash(preferrable):
bin/behat -v --suite=api #NameSpaceYourBundle/your.feature --config=app/config/behat.yml -f pretty
or if you want to save the output as html at web/behat directory then:
bin/behat -v --suite=api #NameSpaceYourBundle/your.feature --config=app/config/behat.yml
Let me know if it works
Note:
I am not sure if you are running selenium server or standalone server, hence adding the step to run selenium standalone server:
Download selenium and chromedriver and place the selenium server .exe and chromedriver.exe in same folder
check with "java -version" and it should not be < 1.6.x
you may need to download compatible selenium server and chrome driver
open command prompt and run the below commands:
cd C:\<folder contains selenium server .exe and chromedriver.exe>
java -Dwebdriver.chrome.driver="chromedriver.exe" -jar selenium-server-standalone-x.xx.0.jar