PHP symfony2 bootstrap assetic:dump error - php

I am trying to use twitter bootstrap in my symfony2.7 project. This is the content on my composer.json file:
"require": {
...
"braincrafted/bootstrap-bundle": "dev-master",
"leafo/lessphp": "0.4.0",
"twbs/bootstrap": "3.0.*",
"jquery/jquery": "1.11.*"
},
Then I configure assetic as follows:
lessphp:
file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
apply_to: "\.less$"
cssrewrite: ~
braincrafted_bootstrap:
less_filter: lessphp
Then the console response is this one when I do the assetic:dump:
PS D:\Web\job-bid> php app/console assetic:dump --force web
Dumping all dev assets. Debug mode is on.
10:17:49 [file+] web/css/bootstrap.css
[Exception] Failed to assign arg #list: line: 50
assetic:dump [--forks FORKS] [--watch] [--force] [--period PERIOD]
[--] []
PS D:\Web\job-bid
What could the problem be?
Edit:
Well I have changed to the latest version of bootstrap 2 and it gives me a different error:
PS D:\Web\job-bid> php app/console assetic:dump web --force Dumping
all dev assets. Debug mode is on.
16:43:18 [file+] web/css/bootstrap.css 16:43:19 [file+]
web/css/bootstrap_bootstrap_1.css 16:43:21 [file+]
web/css/bootstrap_form_2.css 16:43:21 [file+] web/js/bootstrap.js
[RuntimeException] The source file
"D:\Web\job-bid\app/../vendor/twbs/bootstrap/js/transition.js" does
not exist.
assetic:dump [--forks FORKS] [--watch] [--force] [--period PERIOD]
[--] []
PS D:\Web\job-bid>

AFAIK http://leafo.net/lessphp/ is not compatible with Boostrap 3 > 3.0.0, see https://github.com/leafo/lessphp/issues/503
see this more complete answer: https://stackoverflow.com/a/20914166/4989952

Related

Codeception See and Click functions Error out with Selenium running ChromeDriver

I am writing codeception tests with selenium running chrome driver for my local env, which is MacOS, running valet+. I am having issue of getting an error when I try to call methods like see() or click(). However other functions like seeInSource(), executeJS() and grabPageSource() are working fine.
For Example:
$I->see('Go to au site'); //Errors out
while
$I->seeInSource('Go to au site') // works fine
My acceptance.suite.yml is as following.
actor: AcceptanceTester
modules:
enabled:
# - PhpBrowser:
# url: http://npr.test/
- WebDriver:
url: http://npr.test/
browser: chrome
capabilities:
chromeOptions:
w3c: true
goog:chromeOptions:
w3c: true
- \Helper\Acceptance
extensions:
enabled:
- Codeception\Extension\RunProcess:
- chromedriver
step_decorators: ~
The Error I am getting when I use see or click
php vendor/bin/codecept run acceptance --steps
Codeception PHP Testing Framework v4.1.21
Powered by PHPUnit 8.5.16 by Sebastian Bergmann and contributors.
Acceptance Tests (1) -------------------------------------------------------------------------------------------------------------------------
[RunProcess] Starting chromedriver
LandingPageCest: Landing page test
Signature: LandingPageCest:landingPageTest
Test: tests/acceptance/LandingPageCest.php:landingPageTest
Scenario --
I am on url "http://npr.test"
I am on page "/"
I see "Go to au site"
ERROR
----------------------------------------------------------------------------------------------------------------------------------------------
[RunProcess] Stopping chromedriver
Time: 6.38 seconds, Memory: 10.00 MB
There was 1 error:
---------
1) LandingPageCest: Landing page test
Test tests/acceptance/LandingPageCest.php:landingPageTest
[PHPUnit\Framework\Exception] Undefined index: ELEMENT at vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:228
Scenario Steps:
3. $I->see("Go to au site") at tests/acceptance/LandingPageCest.php:16
2. $I->amOnPage("/") at tests/acceptance/LandingPageCest.php:15
1. $I->amOnUrl("http://npr.test") at tests/acceptance/LandingPageCest.php:14
#1 /Users/techlead/Projects/npr-testing/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:228
#2 Codeception\Module\WebDriver->see
#3 /Users/techlead/Projects/npr-testing/tests/_support/_generated/AcceptanceTesterActions.php:329
#4 /Users/techlead/Projects/npr-testing/tests/acceptance/LandingPageCest.php:16
#5 LandingPageCest->landingPageTest
Artifacts:
Png: /Users/techlead/Projects/npr-testing/tests/_output/LandingPageCest.landingPageTest.fail.png
Html: /Users/techlead/Projects/npr-testing/tests/_output/LandingPageCest.landingPageTest.fail.html
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
Also I have looked at issue
Codeception: $i->see(text) but not $i->click(text)
That didn't help me as I am setting my wc3 as true, and if I set it as false my selenium fails to start session.
So after trying a few things what worked for me was to replace my facebook/webdriver to php-webdriver. So my composer json looks like.
{
"require": {
"php-webdriver/webdriver": "^1.11"
},
"require-dev": {
"codeception/codeception": "^4.1",
"codeception/module-phpbrowser": "^1.0.0",
"codeception/module-asserts": "^1.0.0",
"codeception/module-webdriver": "^1.2"
}
}
Run the follwoing commands on your console to add php-driver and remove facebook/webdriver
composer require php-webdriver/webdriver
composer remove facebook/webdriver

Php Module already exist

Hey guys i have a little error i am trying to integrate mongoDB in my symfony project :) But when i do php bin/console i have this error :
PHP Warning: Module 'mongodb' already loaded in Unknown on line 0
Could not open input file: bin/console
I think that happens when i add mongodb.so in my php.ini.
I think if i resolve this it will resolve my error with mongoDB that i explain there : link to other post
Thx for all that will try to help :p
nb : i have composer version 1.6.5 and php 7
Update : I did composer update and that what it returns now when i do php bin/console :
PHP Warning: Module 'mongodb' already loaded in Unknown on line 0
Symfony 3.4.14 (kernel: app, env: dev, debug: true)
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
-n, --no-interaction Do not ask any interactive question
-e, --env=ENV The Environment name. [default: "dev"]
--no-debug Switches off debug mode.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal > output, 2 for more verbose output and 3 for debug
Available commands:
about Displays information about the > current project ....
I got that when i do php --ini :
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed: /etc/php.d/20-bcmath.ini,
/etc/php.d/20-bz2.ini,
/etc/php.d/20-calendar.ini,
/etc/php.d/20-ctype.ini,
/etc/php.d/20-curl.ini,
/etc/php.d/20-dom.ini,
/etc/php.d/20-exif.ini,
/etc/php.d/20-fileinfo.ini,
/etc/php.d/20-ftp.ini,
/etc/php.d/20-gd.ini,
/etc/php.d/20-gettext.ini,
/etc/php.d/20-iconv.ini,
/etc/php.d/20-json.ini,
/etc/php.d/20-mbstring.ini,
/etc/php.d/20-mysqlnd.ini,
/etc/php.d/20-pdo.ini,
/etc/php.d/20-phar.ini,
/etc/php.d/20-simplexml.ini,
/etc/php.d/20-sockets.ini,
/etc/php.d/20-sqlite3.ini,
/etc/php.d/20-tokenizer.ini,
/etc/php.d/20-xml.ini,
/etc/php.d/20-xmlwriter.ini,
/etc/php.d/20-xsl.ini,
/etc/php.d/30-mysqli.ini,
/etc/php.d/30-pdo_mysql.ini,
/etc/php.d/30-pdo_sqlite.ini,
/etc/php.d/30-wddx.ini,
/etc/php.d/30-xmlreader.ini,
/etc/php.d/50-mongodb.ini

Assetic:dump error Assetic\Filter\LessFilter

I am working in Windows and trying to deplay my project in prod on Debian server. I am using svn. I changed my config.yml to handle the path of node and less.
When I try to do :php app/console assetic:dump --env=prod on the server I receive an Error : PHP Catchable fatal error: Argument 2 passed to Assetic\Filter\LessFilter::__construct() must be of the type array, string given, called in /var/www/ales/app/cache/prod/appProdProjectContainer.php on line 549 and defined in /var/www/ales/vendor/kriswallsmith/assetic/src/Assetic/Filter/LessFilter.php on line 54
Herewith my configuration :
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: ['MyAppliCoreBundle']
java: /usr/bin/java
filters:
cssrewrite: ~
cssembed:
jar: %kernel.root_dir%/resources/java/cssembed-0.4.5.jar
less:
node: /usr/lib/nodejs
node_paths: [/usr/lib/node_modules]
apply_to: "\.less$"
cssrewrite: ~
yui_css:
jar: "%kernel.root_dir%/ressources/java/yuicompressor-2.4.8.jar"
assets:
bootstrap_css:
inputs:
- %kernel.root_dir%/../vendor/twbs/bootstrap/less/bootstrap.less
filters:
- less
- cssrewrite
jquery:
inputs:
- %kernel.root_dir%/../vendor/jquery/jquery/jquery-2.1.1.js
output: js/jquery.js
When I try on DEV I get this error :
22:45:00 [file+] /var/www/ales/app/../web/assetic/bootstrap_css.less
[Assetic\Exception\FilterException]
An error occurred while running:
'/usr/lib/nodejs' '/tmp/assetic_lessBjeLzE'
Error Output:
sh: 1: /usr/lib/nodejs: Permission denied
Input:
// Core variables and mixins
#import "variables.less";
#import "mixins.less";
I checked permission and set to 777 /usr/lib/nodejs but nothing change.
If you need more details, don't hesitate.
Symfony2 with bootstrap 3 on debian.
which node return :
/usr/local/bin/node
wich nodejs return :
/usr/bin/nodejs
and echo $NODE_PATH return :
/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
Thanks a lot for your help, I was planning to set in prod this weekend...
I had the same problem and solved it well, first you can try with this configuration:
less:
node: "node"
node_paths:
- "/usr/lib/node_modules"
- "%kernel.root_dir%/../../../node_modules"
if later you have this Error: Cannot find module 'less' you have to install the module:
npm install -g less
I hope I have been helpful!!

Symfony2 framework image doesn't appear

I've got an image on our website that we've had to change as it was a .ico image which isn't widely supported on browsers like google chrome. It was also quiet large so it needed reducing in size. So we've changed the image to info-icon.png rather then server-image.ico.
So, now that we have changed that, run the following commands:
php app/console assetic:dump --env=prod --no-debug
php app/console assets:install ../web --env=prod --no-debug
php app/console cache:clear --env=prod --no-debug
php app/console cache:warmup --env=prod --no-debug
All have come back fine and haven't reported any issues. When we go to our website and look at the source code we can see that the image url has changed to info-icon.png however the link is a 404 error code. The twig code for the image is below:
{% image output="/images/info-icon.png"
'#MyBundle/Resources/public/images/info-ico.png'
%}
<img src="{{ asset_url }}" alt="">
{% endimage %}
P.s. The image name is info-ico.png it isn't a typo we wanted to show the image as a different name. This is also in production mode.
If anyones interested this is the code for the assetic config:
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ 'MyBundle' ]
node: /usr/bin/nodejs
#java: /usr/bin/java
filters:
cssrewrite: ~
uglifycss:
bin: /usr/local/lib/node_modules/uglifycss/uglifycss
no_copyright: true
#apply_to: ['.css$']
uglifyjs2:
bin: /usr/local/lib/node_modules/uglify-js/bin/uglifyjs
no_copyright: true
#apply_to: ['.js$']
optipng:
bin: /usr/bin/optipng
apply_to: "\.png$"
jpegtran:
bin: /usr/bin/jpegtran
apply_to: ['.jpe?g$']
progressive: true
I've also tried clearing the cache manually, using a symlink on the assets:install command and nothing seems to work. Has anyone got any idea's?
The issue was with the assetic:dump command and mis-configuration.
I was running the command with the --no-debug so I couldn't see what was happening however I was getting random characters appearing when running this command. The command was outputting the PNG encoding as the modules for optimising the jpeg's and PNG images were not installed on the production server so simply removing these from the config file and then clearing the cache and warming up the cache. I then run the assetic:dump command again which resolved the issue.

Unable to load Sass / Compass after installing RVM, to use with Assetic in Symfony2

I was trying to use Capifony, which requires Capistrano, which requires Ruby. But my apt version of ruby was old and was throwing syntax errors. So then I installed RVM and did this:
$ rvm use 1.9.3
$ rvm --rvmrc --create use 1.9.3#myapp
$ gem install sass [--pre]
$ gem install compass [--pre]
$ updatedb
$ locate sass | grep myapp | grep bin
$ locate compass | grep myapp | grep bin
Copied and pasted those paths to config.yml
sass:
bin: /usr/local/rvm/gems/ruby-1.9.3-p194#myapp/gems/sass-3.2.0.alpha.277/bin/sass
#apply_to: "\.scss$"
compass:
bin: /usr/local/rvm/gems/ruby-1.9.3-p194#myapp/gems/compass-0.13.alpha.0/bin/compass
apply_to: "\.scss$"
Everything about Compass and Sass worked fine before switching to RVM.
Compass/Sass still seem to work from app_dev.php, but they break when I try to dump assets for production:
$ rm -r app/cache/ # this is how I delete cache, any other way give me errors, even before having this compass problem. This have always worked fine. I removed the * because this code block was interpreting it as a comment
$ php app/console assetic:dump --env=prod --no-debug
Dumping all prod assets.
Debug mode is off.
00:05:36 [file+] /home/www/dev/public/myapp/app/../web/css/fcd6640.css
[Assetic\Exception\FilterException]
An error occurred while running:
'/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby' '/usr/local/rvm/gems/ruby-1.9.3-p194#myapp/gems/compass-0.13.alpha.0/bin/compass' 'compile' '/t
mp' '--config' '/tmp/assetic_compassF1Mv7t' '--sass-dir' '' '--css-dir' '' '/tmp/assetic_compassKDoaEA.scss'
Error Output:
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- sass (LoadError
)
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194#myapp/gems/compass-0.13.alpha.0/lib/compass/dependencies.rb:6:in `rescue in <top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194#myapp/gems/compass-0.13.alpha.0/lib/compass/dependencies.rb:1:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194#myapp/gems/compass-0.13.alpha.0/lib/compass.rb:5:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194#myapp/gems/compass-0.13.alpha.0/lib/compass.rb:4:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p194#myapp/gems/compass-0.13.alpha.0/lib/compass.rb:4:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194#myapp/gems/compass-0.13.alpha.0/bin/compass:20:in `block in <main>'
from /usr/local/rvm/gems/ruby-1.9.3-p194#myapp/gems/compass-0.13.alpha.0/bin/compass:8:in `fallback_load_path'
from /usr/local/rvm/gems/ruby-1.9.3-p194#myapp/gems/compass-0.13.alpha.0/bin/compass:19:in `<main>'
Output:
Unable to load Sass. Please install it with one of the following commands:
gem install sass --pre
Input:
$main-color: red;
body {
color: $main-color;
}
Another error I have been getting:
Error Output:
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find compass (>= 0) amongst [big decimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
Related: #mpapis #jamz Sass broken after install with RVM, using Assetic PHP
I would like to add more tags: compass and sass. Not sure if can be done with higher score.
UPDATE
I added a wrapper like this:
$ rvm wrapper ruby-1.9.3-p194#myapp php sass compass
And edited config.yml again, but now I get these errors alternated, randomly:
Error 1:
[Assetic\Exception\FilterException]
An error occurred while running: '/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby' '/usr/local/rvm/bin/php_compass' 'compile' '/tmp' '--config' '/tmp/assetic_compass0Tmn8t' '--sass- dir' '' '--css-dir' '' '/tmp/assetic_compasssw2S3k.scss'
Error Output: /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby: no Ruby script found in input (LoadError)
Input:
$main-color: red;
body {
color: $main-color;
}
Error 2:
Error Output: /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/shared_helpers.rb:22:in `default_gemfile': Could not locate Gemfile (Bundler::GemfileNotFound)
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler.rb:213:in `default_gemfile'
Compass still works fine through app_dev.php
I guess you need a wrapper:
rvm wrapper ruby-1.9.3-p194#myapp php sass compass
this will generate wrappers which will call proper ruby(rvm) environment, use them like:
sass:
bin: /usr/local/rvm/bin/php_sass
#apply_to: "\.scss$"
compass:
bin: /usr/local/rvm/bin/php_compass
apply_to: "\.scss$"
Solution
Just use lessphp. It can be installed with Composer, and then in config.yml:
lessphp:
php: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
apply_to: "\.less"

Categories