CAT | Symfony
25
Some seats free for the upcoming german symfony training
2 Comments · Posted by Timo Haberkern in Symfony, workshop
There are some seats free for my upcoming german symfony training session (http://bit.ly/adl47z). This training takes place mid-june (16-18th June) in a training center in Heilbronn.
Es sind noch ein paar Plätze für meine kommende offene Symfony-Schulung verfügbar (http://bit.ly/adl47z) Diese findet am 16. bis 18. Juni in einem Trainingszentrum in Heilbronn statt.
No tags
Hi all,
I have just released the version 1.5.0 of the sfAmfPlugin.You can get it from here.
The new version brings some fixes and new features. Most noteably:
- Updated version of SabreAMF inlcuded (latest development version)
- Symfony 1.3 and 1.4 Support
- First version of a AMF Service Browser (thanks to Benoît Gouchet)
The plan for the next version shows improvements for Class Mapping, VO and Caching. And I promise to create a better documentation for it…
No tags
29
Copy&Paste Detector Task for Phing
No comments · Posted by Timo Haberkern in Continuous Integration, General, Phing, Symfony
Hi,
I use the Hudson Continuous Integration system to build my Symfony projects (will write a blog series about this in the next few days). For that I created a new task for the Phing build system. Sebastian Bergamann wrote a Copy&Paste Detector for PHP some time ago (PHPCPD). This small tool scans PHP sourcecode for duplications. You can use the Task in a Phing build file as shown in the following sample:
<phpcpd haltonerror="false">
<fileset dir="${builddir}" id="filestocpd">
<include name="apps/**/*.php" />
<include name="lib/de/**/*.php" />
<include name="lib/task/**/*.php" />
<include name="lib/services/**/*.php" />
<include name="lib/form/**/*.php" />
<include name="lib/model/**/*.php" />
</fileset>
<formatter type="pmd" outfile="reports/pmd-cpd.xml"/>
</phpcpd>
The CPD task is incorporatated in the current Phing trunk. If you want to use it you need to checkout the Version2.4.0 RC at the moment. The PEAR Installer version doesn’t contain the Task at the moment.
Maybe this is useful for you too. Stay tuned for more informations on Symfony and Continuous integration
No tags
5
sfAmfPlugin 1.4.2
1 Comment · Posted by Timo Haberkern in AMF, Flex, General, Symfony, doctrine
I released a new version of the Symfony-Plugin sfAmfPlugin som hours ago. With the new version the communication between Flex and Symfony is easier than ever.The new version brings big improvements regarding the Doctrine Adapters. Relations between classes are handled better now. The error_reporting is working now as it should and there is a default implementation of a gateway module included.I hope you like it and find it useful. And as always I would like to hear from you if there are bugs or feature requests.Get it while it’s hot
Timo
No tags
3
Serving PDF Files through Symfony Controllers
10 Comments · Posted by Timo Haberkern in General, Symfony
A lot of web applications offer to download some kind of PHP file. Maybe you want to implement some kind of export feature or you have paid content in form of a PDF or other media or you just want to secure your PDF files in the same way as the rest of your application (i.e. username/password). If this is the case you wouldn’t place your PDF-files in a subfolder of the web-Directory of your Symfony project, because all these file can be accessed directly via browser.
So how to serve your PDF-Files through a Symfony controller? it is an easy one. Just assume you put your pdf-files in a directory called “media” on the root-level of your Symfony-project.
root |-- apps |-- cache |-- config | |-- demo.pdf |-- media |-- lib |-- web
These files cannot be reached by Browser, so we need a new routing information for Symfony to get them accessible via the webbrowser. For that open the routing.yml of your application and add the following rule topmost in this file.
mediafile:
url: /media/:filename.pdf/*
param: { module: media, action: show }
From now on if you try to access a PDF-File in the media-folder (i.e. http://domain/media/demo.pdf) the media-Module with the action show is called. That was easy but how to implement this action. First you need to create the media module with the symfony command line tool:
$> symfony generate:module appname media
Afterwards add the following method to the class in the media/actions/actions.class.php file:
public function executeShow(sfWebRequest $request) {
// being sure no other content wil be output
$this->setLayout(false);
sfConfig::set('sf_web_debug', false);
$pdfpath = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'media'
.DIRECTORY_SEPARATOR
.$request->getParameter('filename').'.pdf';
// check if the file exists
$this->forward404Unless(file_exists($pdfpath));
// Adding the file to the Response object
$this->getResponse()->clearHttpHeaders();
$this->getResponse()->setHttpHeader('Pragma: public', true);
$this->getResponse()->setContentType('application/pdf');
$this->getResponse()->sendHttpHeaders();
$this->getResponse()->setContent(readfile($pdfpath));
return sfView::NONE;
}
Thats it! You can improve this Action method a little bit. For example you can add a “download”-switch. If this switch is set to 1 the file is downloaded instead of shown in the browser (i.e. http://domain/media/demo.pdf/download/1).
public function executeShow(sfWebRequest $request) {
// being sure no other content wil be output
$this->setLayout(false);
sfConfig::set('sf_web_debug', false);
$pdfpath = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'media'
.DIRECTORY_SEPARATOR
.$request->getParameter('filename').'.pdf';
// check if the file exists
$this->forward404Unless(file_exists($pdfpath));
// Adding the file to the Response object
$this->getResponse()->clearHttpHeaders();
$this->getResponse()->setHttpHeader('Pragma: public', true);
$this->getResponse()->setContentType('application/pdf');
// download-switch
if ($request->getParameter('download', 0) == 1) {
$this->getResponse()->setHttpHeader('Content-Disposition',
'attachment; filename="'.
$request->getParameter('filename').'"');
}
$this->getResponse()->sendHttpHeaders();
$this->getResponse()->setContent(readfile($pdfpath));
return sfView::NONE;
}
As we now use a Symfony-Controller you can do just use the complete Symfony infrastructure. You like to secure the PDF-files? Just enable the Symfony security mechanisms (is_secure: on in the security.yml) and only logged in users can download them. In the same way you can create paid content. Or you can add watermarks to your PDF using Zend_Pdf for example.
Hope this is helpful for you.
No tags
5
sfAmfPlugin 1.3.0 released
No comments · Posted by Timo Haberkern in AMF, Flex, General, Symfony, doctrine
Just want to inform you that my sfAmfPlugin for Symfony-Flex-Communication was released in version 1.3.0.
Most noticeable changes:
- Fixing a bug with PHP Strict mode (thanks to Daniel Holmes for spotting this one)
- Adding the possibility to store the services in all lib-folders of a project (app, module, project, plugins)
- Fixing different bugs with AMF conversion of Doctrine objects (thanks to Patrick Schirch for bugging me about them)
I’m still working to get the Doctrine support better, there will be much more about this in the next version of the plugin. Class mapping is also a thing I want to improve a lot. So stay tuned and watch out for future versions
No tags
16
sfAmfPlugin 1.2.3 for Flex/Symfony released
No comments · Posted by Timo Haberkern in AMF, Flex, General, Symfony
Hi,
just for your information: I released the version 1.2.3 of the sfAmfPlugin earlier this day. The new version is a pretty important update so please install the new version.
The most important change is the fix of the bug taht caused problems with the usage of packages for the service classes
Installation as always:
$> symfony plugin:install sfAmfPlugin
If you want more information about the plugin vistit the symfony plugin page or read the the HelloWorld example blog post.
Timo
No tags
9
sfAmfPlugin version 1.2.0 released
No comments · Posted by Timo Haberkern in Flex, General, Symfony
Hi all,
i just released the new version 1.2.0 of the AMF-Plugin for Symfony (http://www.symfony-project.org/plugins/sfAmfPlugin/1_2_0)
There are some new features in this version:
- Updated SabreAMF to the most current version 1.2.203
- Added a fix for Service-Classes with packages in the class name
- More work on comments and documentation
- Added Symfony 1.2.0 compatibility
- Added a new commandline-task with that you can create a new Service class
The most important new feature is the new task. You can now create a service class via command line:
$ symfony amf:create-service User will create a file /lib/services/UserService.class.php
$symfony amf:create-service –package=de.shiftup.project User will create /lib/services/se/shiftup/project/UserService.class.php
Get it while it is hot
As always: Feedback wanted!
No tags
If you think about the best IDE you will probably think about eclipse with the PDT-Plugin, Netbeans or Kommodo. None of them has special support for the Symfony-Framework. As I wrote in an earlier post I’m using eclipse for my daily work. With some enhancements it is a pretty good IDE for Symfony-Development. Netbeans catched up with the last releases an there is a special Symfony-Support planned in one of the future releases.
Last week there was a new release of the Windows-PHP-IDE PHPEdit. Since Version 3.2 there is an excellent Symfony support in this IDE. A bunch of features makes the development with Symfony a lot more productive. I couldn’t resist and took a deeper look at this software. It was the first time that I used PHPEdit an I’m surprised on how good it is.
Wizards
PHPEdit has a lot of wizards for creating Symfony-Projects and different Symfony artifacts (i.e. modules, actions…). For developers who dont know all of the symfony command line tasks and all of their parameters, these wizards are a great help.
Commands
PHPEdit installs a plugin that allows the IDE to get information about all tasks of the current project. The context menu of the project is file-sensitive. So you will get other tasks in the context menu when clicking on a application than clicking on a module or project. All Symfony tasks are available via context menu. Most of them with an upcoming wizard in which you can set the parameters by mouse clicks
Code Completion and Editor
The Editor has everything you can think of and support for all neccessary file formats (i.e. YAML) are included. Code-Folding,Line-Numbers, Smart Idention and others are available. Plus you have a great IntelliSense support. The Editor knows even the Symfony-Framework functions of the classes. You can jump between Actions and View-Template what is solving one of the most annoying problems if you are working on a large project and have a lot of action.class.php files open.
Conclusion
The makers of PHPEdit did a wunderful job. The symfony support is how I it should be in every IDE
Beside of this Framework-Specific features there is all you need for PHP-Development. A good PHP-Editor with IntelliSense and PHP-Debugging, Project management, everything is on board and pretty good. The only drawback is that PHPEdit is not freely available. It has a commercial license starting with 89.- Euros for the basic feature edition. If you are not using windows another drawback is that PHPEdit is only available for windows.
I’m still surprised why I never used this IDE before because it has everything you need for PHP development. Maybe it was because of its commercial license. For now it is the best Symfony IDE. The Framework-Support is outstanding. Lets see how the planned Symfony-Support in Netbeans can compete with this.
Development · IDE · Symfony
11
German Symfony trainings
1 Comment · Posted by Timo Haberkern in Model, Propel, Symfony, doctrine, workshop
Hello all,I just anounced the dates and locations for my german symfony trainings/workshops. The workshops take place in Stuttgart, Hamburg and Berlin. Language of the workshops is german.
You can find more information and prices at the following training-website
Maybe we can see us at one of these events
No tags

