What is the safest way of passing arguments from server-side PHP to client-side JavaScript [duplicate]

My favorite way is : <?php $var = array( ‘prop1’ => ‘value1’, ‘prop2’ => ‘value2’, // … ); ?> <script type=”text/javascript”> var varNameSpace = <?php echo json_encode($var); ?>; alert( varNameSpace.prop1 ); // -> ‘value1’ </script> Using json_encode() ensures that the values passed to Javascript are escaped and well formatted. Using a common variable container also … Read more

PHP ORMs: Doctrine vs. Propel

I’d go with Doctrine. It seems to me that it is a much more active project and being the default ORM for symfony it is better supported (even though officially the ORMs are considered equal). Furthermore I better like the way you work with queries (DQL instead of Criteria): <?php // Propel $c = new … Read more

php/symfony/doctrine memory leak?

Tried doing $cupo->save(); $cupo->free(); $cupo = null; (But substituting my code) And I’m still getting memory overflows. Any other ideas, SO? Update: I created a new environment in my databases.yml, that looks like: all: doctrine: class: sfDoctrineDatabase param: dsn: ‘mysql:host=localhost;dbname=…….’ username: ….. password: ….. profiler: false The profiler: false entry disables doctrine’s query logging, that … Read more

How to specify Composer install path?

It seems that you can define the vendor dir to be something else (plugins in your case): { “config”: { “vendor-dir”: “plugins” } } Then, you might rename the package name to not have a level dir inside, like: “package”: { “name”: “sfGuardPlugin”, So, your composer.json should look like this: { “config”: { “vendor-dir”: “plugins” … Read more