symfony2 assetics yui compressor on windows (path syntax) - windows

I'm trying to get assetics running with the yui compressor and, if this is running, sass. Right now, both don't work. When removing all filters from config.yml and the twig template, it works and php app/console assetic:dump does copy the css and js files.
Now I want to add the yui compressor and my config.yml looks like this:
assetic:
debug: %kernel.debug%
use_controller: false
filters:
yui_js:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.6.jar
Adding the filter to the template and running assetic:dump again ends in the following error (translation of message by me):
[RuntimeException]
The syntax for filename, directory name or drive name is wrong
I found an article telling me to specify the path to java.exe, so I add this to config.yml:
assetic:
..
java: C:/Program Files (x86)/Java/jre6/bin/java.exe
..
Now assetic:dump tells me:
[RuntimeException]
The COMMAND "C:/Program" is either written wrong or
I tried playing around with both variables (using \ or \ instead of /, adding single or double quotes, working with short alias Progra~1 or Progra~2) in the config, but I didn't get anywhere. The both errors comming up all the time. Maybe someone can point me in the right direction.

Ok, I figured it out. Man, this one was brutal.
Let's start with the easy stuff. A working version of the config.yml can look like this:
assetic:
debug: false
use_controller: false
java: C:\Program Files (x86)\Java\jre6\bin\java.exe
sass: C:\Program Files (x86)\Ruby192\bin\sass.bat
filters:
scss: ~
yui_js:
jar: %kernel.root_dir%\Resources\java\yuicompressor-2.4.6.jar
For some reason, assetic is always importing a whole directory for scss, so I had to make a combine.scss which imports the other scss files in the correct order.
And now it gets ugly, as one have to change the assetics core in order to get this working. The developers of assetic know this bug and I think it is fixed in some development trunk/branch but not the stable one.
The Assetic\Util\ProcessBuilder has to be changed on line 95
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
,line 103
$script .= ' '.implode(' ', array_map('escapeshellarg', $args));
and line 110
return new Process($script, $this->cwd, null, $this->stdin, $this->timeout, $options);
I hope this bug get fixed soon and till then anybody trying to get it working finds this thread... Took me like 8 hours of debuging, reading and trying different approaches.

Answer by Boo Nov 19 at 22:53 did work for me by changing everything he mentioned in Assetic\Util\ProcessBuilder (I ignored line 95 as it looks the same as in my file)
Now it works on windows. Thanks!
Just to confirm. Im using Symfony 2.0.7 and yuicompressor-2.4.7

For other users who use window server 2008 r2 :
Maybe you should change the C:\windows\Temp folder property to 777 (read/write) for the IIS user / or the machine's normal user
please unpack the ruby.7z from rubyinstaller.org , and go to C:\_ruby193\bin , in this unpack position you should exec the CMD prompt , type :
ruby -S gem install sass
so that you will get the sass.bat in that position
It's time to use Boo's best answer , and please notice that in symfony2 dev env maybe it's not necessary to change the use_controller to false (in the config.yml) , because there's another use_controller in the config_dev.yml (set to true) , and in routing_dev.yml there's also a _assetic router , they're perhaps associated.

Related

docpad-plugin-thumbnails appears to hang

Symptom...
docpad run results in the usual messages but it never gets past:
Currently on writeFiles at 45/45 100% =================================================
Environment -
osx 10.8.3
node v0.10.0
npm i.2.14
docpad 6.34.2
ImageMagick v6.8.5-3, which has been confirmed working from the command line
Steps to reproduce...
Install kitchensink skeleton (or the jade and adapt the coffeekup code in example)
Install docpad-plugin-associatedfiles
and docpad-plugin-thumbnails
Create an associate-files directory in Files and drop in another directory called 'gallery' with some .jpg's with no spaces in the filenames
Create a new page called gallery.html.coffee and cut and paste the coffeeKup example from thumbnails' read me file :) - see below.. [I've also tried simplifying it down to the bare functionality to show the thumbnails, by cutting out the checks on file-types and the links to the original sized images.]
docpad run and watch whilst it doesn't finish...
Observations -
If you remove the reference to getThumbnails and just list the associated files it all works peachy.
Filenames for the thumbnails that would be generated show up in the generated HTML file - but the thumbnails do not show up in the out directory (or anywhere else as far as I could find)
So questions...
am I missing the startlingly obvious? (here's hoping)
how do I inspect docpad.log?
I read the instructions for debugging, but so far I've not made sense of them enough to step into any code - sorry - I'm a real novice.
Thanks for any input,
The page looks like this:
---
layout: default
title: Gallery
---
image_exts = ['jpg', 'JPG', 'jpeg', 'JPEG', 'png', 'PNG']
images = #getDocument().getAssociatedFiles().findAll({extension: $in: image_exts}).toJSON()
for image in images
a href: image.url, -> img src: #getThumbnail(image.url, w: 100, h: 100), alt: image.name
I had the same problem, and I used the command:
$ docpad --debug 7 run
If you get the error "spawn ENOENT", you must install graphicsmagick, because the gm library needs some configuration if you use imagemagick.
You can try this command:
npm install --save docpad-plugin-thumbnails
I was facing the similar issue and it worked for me.. hope this helps!
Did you configure the plugin to use imageMagick in your docpad.coffee?
plugins:
thumbnails:
imageMagick: true

Custom templates with phpDocumentor 2

I've been trying to get a custom template to work with PHPDocumentor (2) without much luck. The documentation on their site is incomplete and I'm kind of stumped.
What I've done is downloaded a copy of a complete template and reference it in my command, like so:
php phpdoc.php
--template=/path/to/customtemplate/
-d /path/to/php/source/files
-t /path/to/generated/content/
The command runs fine: it generates the documentation correctly but appears to be ignoring the --template option - at least, any changes I make to the template files in the /customtemplate folder are ignored.
Anyone have any idea?
(Thanks in advance!)
Ben
Instead of declaring the template command on the CLI you might try changing your phpdoc.dist.xml configuration file so that it pulls the template name or path from there directly.

How to use SCSS filter in Symfony2 under Windows?

Actually, this is two questions:
What is the correct way to use the SCSS filter in my Symfony project in Windows (in Twig templates) ?
I mean, how do i use the scss binary in windows?
Also, Do I necessarily need to use Compass? and "HOW" do i use compass if I have installed it?
Extension : Here is some configuration I have done:
In app/config/config.yml
assetic:
debug: %kernel.debug%
use_controller: false
filters:
scss:
bin: "%kernel.root_dir%/Resources/libs/scss"
compass:
bin: "%kernel.root_dir%/Resources/libs/compass"
In my twig file:
{% stylesheets
'#PlaylyfeBaseBundle/Resources/public/css/base.scss'
'#PlaylyfeBaseBundle/Resources/public/css/another.scss'
filter='scss'
output='css/compiled/total.css'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
But, when i load the page, I get the following error (inside the css file)
[exception] 500 | Internal Server Error | RuntimeException
[message] The filename, directory name, or volume label syntax is incorrect.
[1] RuntimeException: The filename, directory name, or volume label syntax is incorrect.
at n/a
in C:\wamp\www\Symfony\vendor\assetic\src\Assetic\Filter\Sass\SassFilter.php line 162
at Assetic\Filter\Sass\SassFilter->filterLoad(object(Assetic\Asset\FileAsset))
in C:\wamp\www\Symfony\vendor\assetic\src\Assetic\Filter\FilterCollection.php line 62
at Assetic\Filter\FilterCollection->filterLoad(object(Assetic\Asset\FileAsset))
in C:\wamp\www\Symfony\vendor\assetic\src\Assetic\Asset\BaseAsset.php line 83
at Assetic\Asset\BaseAsset->doLoad(&#039
I can only speak for Compass since is what I use but the same issues/problems most likely relate to the SASS/SCSS filters as well.
There are many known file path issues with Compass on Windows systems:
Issue #748: File Path normalization to support Windows systems
Pull Request #554: Fixes a bug on Windows systems
Comments on commit 539f206
... and also fixes proposed to Assetic to deal with them:
Pull Request #154: Compass problem on Windows, ruby.exe not found
Pull Request #152: Until Compass issue 554 is not corrected
Issue #131: You must compile individual stylesheets from the project directory.
I've found that doing the following was necessary for everything to work together...
#1. Make sure %ruby%\bin is in your environment PATH variable:
Example:
PATH = "...;C:\Ruby\1.9.2\bin"
#2. Edit %ruby%\bin\compass.bat to use absolute paths:
#ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
#"C:\Ruby\1.9.2\bin\ruby.exe" "C:/Ruby/1.9.2/bin/compass" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
#"C:\Ruby\1.9.2\bin\ruby.exe" "%~dpn0" %*
#3. Revert 539f206 manually in compiler.rb # line ~10:
Note: This step may not be required on the latest Ruby/Compass versions. (Reference)
Path: %ruby%\lib\ruby\gems\1.9.1\gems\compass-*\lib\compass\compiler.rb
# self.from, self.to = from.gsub('./', ''), to
self.from, self.to = File.expand_path(from), to
#4. Make sure Assetic is configured properly:
Example (config.yml):
assetic:
debug: %kernel.debug%
use_controller: false
filters:
cssrewrite: ~
compass:
bin: %compass.bin%
yui_js:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
yui_css:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
I use %compass.bin% in my parameters file so that I can ease the transition of the codebase between Windows and *nix systems, so my parameters.yml looks like this:
# Assetic
compass.bin: C:\Ruby\1.9.2\bin\compass.bat
#5. (Optional) Upgrade Assetic and AsseticBundle:
I have Assetic and AsseticBundle tagged to the very last possible commit that works with Symfony 2.0.x in my deps file:
[assetic]
git=http://github.com/kriswallsmith/assetic.git
version=ac71449e46bed22c276da26bf54ab2f733b3801d
[AsseticBundle]
git=http://github.com/symfony/AsseticBundle.git
target=bundles/Symfony/Bundle/AsseticBundle
version=da4a46ce37557dcf3068b8493b12bdbbe47455e2
Make sure to replace %ruby% in all of the paths above with your actual path to ruby.exe, mine being C:\Ruby\1.9.2.
Steps #2 and #4 may or may not be required, but over the course of my time fighting with this issue, it is where I've ended up and my setup works (which is all I care about!).
Good luck!
Side question: Is your path to the SCSS/Compass binaries really in %kernel.root_dir%/Resources/libs?
Unfortunately the twig scss extension is broke on windows. It is a known problem. I spent some time trying to come up with a work around but to no available. I found it best to just use the scss executable with the --watch parameter to simply create the css files and store them in the Resource/public directory. That can also simplify some deployment issues as you don't need to worry about having scss on your servers.
Use of compass is not required for scss. Think of it as a library of useful bits of css. For example, if you ever get an urge to do css rounded edges, a Compass mixin will generate all of the vendor specific custom tags. Refer to the documentation for details on using it.
In my case after hours of searching and trying many solutions, this worked for me:
In 'app/config/config.yml' add:
parameters:
# Assetic
assetic.filter.compass.bin: D:/Ruby193/bin/compass
D:/Ruby193/bin/compass will depend on your Ruby path.
See screenshot:
http://s23.postimg.org/3n2oc5wh7/MY_SOLUTION_THAT_I_FOUND.jpg
My system:
Windows 7 ultimate,
Ruby 1.9.3,
Symfony 2.4.3

Call to undefined function mysql_connect [duplicate]

This question already has answers here:
Fatal error: Call to undefined function mysql_connect() in C:\Apache\htdocs\test.php on line 2
(2 answers)
Closed 3 months ago.
I just installed PHP and Apache on my home PC. When I try to call function mysql_connect I get:
fatal error: call to undefined function mysql_connect.
I have loaded php.ini where I have uncommented lines extension=php_mysql.dll and
extension=php_mysqli.dll and changed extension directory to extension_dir = "C:\php\ext" - which is the directory where files php_mysql.dll and php_mysqli.dll are. How can I fix this problem?
Output of phpinfo():
http://jsfiddle.net/MMTwA/
After looking at your phpinfo() output, it appears the mysql extensions are not being loaded. I suspect you might be editing the wrong php.ini file (there might be multiple copies). Make sure you are editing the php file at C:\php\php.ini (also check to make sure there is no second copy in C:\Windows).
Also, you should check your Apache logs for errors (should be in the \logs\ directory in your Apache install.
If you haven't read the below, I would take a look at the comments section, because it seems like a lot of people experience quirks with setting this up. A few commenters offer solutions they used to get it working.
http://php.net/manual/en/install.windows.extensions.php
Another common solution seems to be to copy libmysql.dll and php_mysql.dll from c:\PHP to C:\Windows\System32.
Background about my (similar) problem:
I was asked to fix a PHP project, which made use of short tags. My WAMP server's PHP.ini had short_open_tag = off.
In order to run the project for the first time, I modified this setting to short_open_tag = off.
PROBLEM Surfaced:
Immediately after this change, all my mysql_connect() calls failed. It threw an error
fatal error: call to undefined function mysql_connect.
Solution:
Simply set short_open_tag = off.
My PC is running Windows 7 (Apache 2.2 & PHP 5.2.17 & MySQL 5.0.51a), the syntax in the file "httpd.conf" (C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf) was sensitive to slashes.
You can check if "php.ini" is read from the right directory. Just type in your browser "localhost/index.php". The code of index.php is the following:
<?php
echo phpinfo();
?>
There is the row (not far from the top) called "Loaded Configuration File". So, if there is nothing added, then the problem could be that your "php.ini" is not read, even you uncommented (extension=php_mysql.dll and extension=php_mysqli.dll). So, in order to make it work I did the following step. I needed to change from
PHPIniDir 'c:\PHP\'
to
PHPIniDir 'c:\PHP'
Pay the attention that the last slash disturbed everything!
Now the row "Loaded Configuration File" gets "C:\PHP\php.ini" after refreshing "localhost/index.php" (before I restarted Apache2.2) as well as mysql block is there. MySQL and PHP are working together!
You have probably forgotten to restart apache/wamp/xamp/whatever webserver you use, you need to do that in order to make it work
Check your php.ini, I'm using Apache2.2 + php 5.3. and I had the same problem and after modify the php.ini in order to set the libraries directory of PHP, it worked correctly. The problem is the default extension_dir configuration value.
The default (and WRONG) value for my work enviroment is
; extension_dir="ext"
without any full path and commented with a semicolon.
There are two solution that worked fine for me.
1.- Including this line at php.ini file
extension_dir="X:/[PathToYourPHPDirectory]/ext
Where X: is your drive letter instalation (normally C: or D: )
2.- You can try to simply uncomment, deleting semicolon. Include the next line at php.ini file
extension_dir="ext"
Both ways worked fine for me but choose yours. Don't forget restart Apache before try again.
I hope this help you.
Hi I got this error because I left out the ampersand (&) in
; php.ini
error_reporting = E_ALL & ~E_DEPRECATED
Be sure you edited php.ini in /php folder, I lost all day to detect error and finally I found I edited php.ini in wrong location.
After change our php.ini, make sure to restart Apache web server.
Just for future reference, copying all these extension files to Windows/System or Windows/System32 is unnecessary.
All that is required is a copy of the php.ini file you edit in the PHP dir to copied to the root Windows dir.
phpinfo will clearly explain the below:
Configuration File (php.ini) Path C:\Windows
Logical sense will explain that php wants to load a config located in the Windows dir. :-)
One time I had a problem while using Off instead of off. And also check the pads one more time... The path has to be exact. Also add the following line to your environmental variable.
C:\your-apache-path\bin; C:\your-php-path\bin;C:\your-mysql-path\bin
If you are in Windows, right click My Computer, select properties, and navigate to the Advanced tab... (is Windows 7). Click on Advanced system settings first then select the Advanced tab and then Environmental variables. Select PATH and click on Edit. Make a copy of the string in a .txt file for back up (it might be empty)--- set your environmental variables... Log out and log back in.
Since mysql_connect This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used.
by default xampp does not load it automatically
in your php.ini file you should uncomment
;; extension=php_mysql.dll
to
extension=php_mysql.dll
Then restart your apache you should be fine
This same problem drove me nuts (Windows 10, Apache 2.4, MySql 5.7). For some reason (likely PATH related), the .dlls would not load after uncommenting the correct exension dlls and extension_dir = "ext" in php.ini. After trying numerous things, I simply changed "ext" to use the full directory path. For example. extension_dir = "c:/phpinstall/ext" and it worked.
I think that you should use mysqli_connect instead of mysql_connect

phpDocumentor on legacy code

Can phpDocumentor be used to generate HTML docs for some legacy code that does not necessarily conform to its standard?
I'd like to generate some preliminary documentation for an old code tree and later on start improving my comments and add the appropriate # tags as I get fluent with phpDocumentor. I've never used this piece of software before and the examples I've found focus on how to write new code that conforms to its syntax and generate HTML file by file with the -f parameter.
I've installed latest phpDocumentor through the PEAR command line installer and tried this little *.bat file on Windows XP:
#echo off
phpdoc ^
--directory "\\server\project\trunk" ^
--target "C:\tests\project-doc"
... but this is all I get:
PHP Version 5.3.5
phpDocumentor version 1.4.3
Parsing configuration file phpDocumentor.ini...
(found in C:\Archivos de programa\PHP\pear\data/PhpDocumentor/)...
done
Maximum memory usage set at 256M after considering php.ini...
using tokenizer Parser
directory: '' not found
I've also tried mapping the UNC path to a drive letter:
#echo off
phpdoc ^
--directory "I:\" ^
--target "C:\tests\project-doc"
... but:
PHP Version 5.3.5
phpDocumentor version 1.4.3
Parsing configuration file phpDocumentor.ini...
(found in C:\Archivos de programa\PHP\pear\data/PhpDocumentor/)...
done
Maximum memory usage set at 256M after considering php.ini...
using tokenizer Parser
a target directory must be specified
try phpdoc -h
This error message is the same if I create "C:\tests\project-doc" before.
What's exactly wrong in my syntax?
phpDocumentor can indeed run against "undocumented" code. It builds its docs based on the code itself, and uses the docblocks as additional info (and additional organization, in the case of #package and #subpackage tags).
I'd suggest starting with phpDocumentor against your existing code, and work towards clearing out the warnings you see in the errors.html file that results -- this file is generated in the top level of your output docs, but there isn't any link to it from the output docs.
Once you have those cleared, you can start running phpDocumentor with the -ue argument (--undocumentedelements), which will add new warnings to errors.html, highlighting (in much greater detail) things that still need to be documented in docblocks.
Now, as for the issue you're having trying to run the program against code on a shared drive, I'm not sure what's wrong there. The script is clearly able to execute PHP and find the phpDocumentor code itself. You might try putting the arguments in the same line, rather than using the ^ as a line-feed escape character, and perhaps remove the quotes around the paths (since no spaces exist in the paths).
I think I've found what the issue is. The parameter parser is very picky and it doesn't like neither UNC paths nor bare root directories. If I replace this:
--directory "I:\"
... with this:
--directory "I:\."
... it finally starts running.
I suppose it's a bug. Their bug tracker doesn't seem to be public so I don't know if it's a known issue.

Resources