Enable Twig debug in Symfony2
To enable the debug tag in Twig, add the following to app/config/config_dev.yml
services: twig.extension.debug: class: Twig_Extensions_Extension_Debug tags: - { name: twig.extension }
Afterwards clear the cache and use the debug extension:
{% debug my_var %}
Sources
eZPublish access/change user account from PHP
It took me some time to figure out how to access and change a user account in eZPublish from PHP. Here’s an example how to achieve this:
<?php // user node $node = eZContentObjectTreeNode::fetch($nodeID); // user object $dataMap = $node->dataMap(); // change attribute $firstname = $dataMap['firstname']; $firstname->setAttribute('data_text', 'Foo'); $firstname->sync(); // user account attribute $user = $dataMap['user_account']; $userData = $user->content(); // user settings $userSetting = eZUserSetting::fetch($user->ContentObjectID); // get account status $isEnabled = $userSetting->attribute('is_enabled'); // enable user account $userSetting->setAttribute('is_enabled', 1); $userSetting->store();
Or if you just want to access the user account object or the user setting directly:
<?php // user account object $user = eZUser::fetch($objectID); // user settings $userSetting = eZUserSetting::fetch($objectID);
Continuous Integration with phpUnderControl and Git
I was looking for a decent continuous integration solution for my PHP projects for some time now, but always had the problem that most of the described solutions used SVN instead of Git as VCS system. Yesterday I found an article which describes the setup exactly as I needed it: phpUnderControl with Git on a Debian/Ubuntu system. Using the article, I managed to set up a working system quickly, which basically works as expected: CruiseControl checks the repository for modifications and starts the build process if there are any new commits. The build process includes generating API documentation (phpdocumentor), running static code analysis (php-codesniffer) and executing unit tests (phpunit). If the build succeeds, the results are published and can be accessed through a nice webinterface powered by phpUnderControl (see screenshot above which I stole from the phpUnderControl site).
However, the described setup has a few issues which bugged me:
- CruiseControl runs from the shellscript as root, posts all output to the console and is not automatically started at boot time.
- CruiseControl runs on port 8080, but I wanted to manage access to the webinterface through the apache which is already running on the box
- There’s no authentication – everybody can access my CI server, see the build details and start new builds through the webinterface.
FH Raumbelegung: iCal Support für Wochenübersicht
Ab sofort gibt es in meinem Raumbelegung-Webservice die Möglichkeit, die Wochenübersicht via iCal abzurufen. Dadurch lässt sich der Service komfortabel in Kalenderapplikationen (z.B. der Thunderbird-Extension Lightning) verwenden. Verwendung: einfach an eine Wochenübersicht den Parameter format/ical anhängen oder die entsprechenden Links am Ende der Übersicht verwenden.
Um zum Beispiel immer die aktuelle Woche des Studiengangs WI07 als Kalender in meinem Thunderbird anzeigen zu können, habe ich dort folgende URL als iCal-Quelle angegeben:
http://raumbelegung.stud.ailoo.net/week/show/class/wi07-vz/format/ical
Vorschläge sind wie üblich willkommen :)
Set up a Zend Framework application using Zend_Application (including PHPUnit setup)
Today I spent some time setting up a new Zend Framework application using ZF 1.8.0 Beta 1 and the new component Zend_Application. Using that component, all bootstrapping is done by Zend_Application_Bootstrap and so-called resource plugins. Such resource plugins are responsible for initialization of single components such as front controller, database or the view. This way, the whole bootstrapping is nicely modularized and keeps some headache away. In addition, the majority of settings can be set in the application config file. As I ran into some issues, I’d like to note the required steps and hope that it’s useful so someone. I won’t explain the files in detail, you can find enough information about components and parameters on the manual and the quickstart, but you should get to a working setup with just copy&pasting the code here ;)
Basically a big part of this setup can be done using the new Zend_Tool CLI, however I had some problems setting it up, so I’ve done it manually (however most of the code is the one generated by Zend_Tool).
Set up symfony 1.2 on Debian/Ubuntu
Just wanted to give symfony a try and ran into some issues to set it up the way I wanted. Therefore I’d like to note the required steps.
First, install symfony via PEAR.
pear channel-discover pear.symfony-project.com pear install symfony/symfony-1.2.4
This sould install symfony and make the symfony executable available in your PATH.
~$ symfony -V symfony version 1.2.4 (/usr/share/php/symfony)
Create a directory for your vhost and create a new project.
mkdir /var/www/myproject cd /var/www/myproject symfony generate:project myproject
Create an example application in your project.
symfony generate:app frontend
Link the symfony resources to the project’s document root.
cd web ln -s /usr/share/php/data/symfony/web/sf/
This should get you up and running with symfony. You just need to configure your server for the vhost. For personal preference, I’d like to have my document root directory named public instead of web. The following steps are needed to achive this.
Rename the document root directory.
mv web public
Add this line to config/ProjectConfiguration.class.php:
<?php public function setup() { $this->setWebDir($this->getRootDir() . '/public'); // for compatibility / remove and enable only the plugins you want $this->enableAllPluginsExcept(array('sfDoctrinePlugin', 'sfCompat10Plugin')$ }
Magento: access a dropdown attribute value
In Magento it is possible to access a product’s attributes with a simple getter method. Let’s get the attribute test:
<?= $_product->getTest() ?>
This works as long as test is an attribute of type ‘text’. If the attribute is a dropdown, the method will just return the id of the selected option. To get the dropdown text, you need to call another method:
<?= $_product->getAttributeText('test') ?>
Magento design resources
As the documentation on Magento is a bit…spread around the web: here’s a collection of links to guides and hints how to deal with magento’s templating system (partially german). I will add more as I find them.
- Designer’s Guide to Magento
- Designer’s Guide to Magento (PDF)
- Theming Magento Commerce (many links are from there)
- Designing for Magento
- Magento folder structure
- How to build a template with blocks
- Add a new layout template
- Change texts in locale file
- List of available XML handles
- Terminologie im Online-Shop Magento
Screencasts
Raumbelegung Update
Wieder ein Update für den Raumbelegungs-Webservice: das Webinterface wurde (zumindest für vernünftige Browser) zum Großteil webzweinulljqueryajaxifiziert ™. Außerdem gibts mittlerweile den Desktopclient in der aktualisierten Version für die neue Basis zum Download auf der Projektseite.