Symfony-Zone | Timo Haberkern blogs about symfony

CAT | General

Jul/10

31

Letzte offene Symfony Schulung in 2010

Hallo,

vom 29.09. bis 01.10. werde ich meine für dieses Jahr letzte offene Symfony-Schulung halten. Der Schulungsort wird voraussichtlich Heilbronn sein (Baden-Würtemberg). Die Schulung kostet 990.- Euro pro Person und dauert 3 Tage.  Mehr Informationen auch zu den Schulungsinhalten gibt es hier.

No tags

Apr/10

16

Netbeans Settingsfile for Symfony

As I’m working with Netbeans when developing Symfony-Applications under Windows I created some Code Templates and Shortcuts to work more effective with Netbeans and Symfony. If you are interessted you can download the Settingsfile and import it to your Netbeans installation.

You can get it here: http://www.symfony-zone.com/wordpress/netbeans/

No tags

Jan/10

4

German symfony trainings 2010

Hello all,I just anounced the dates and locations for my german symfony trainings/workshops. The workshops take place in Stuttgart and Heilbronn. The 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

Oct/09

23

Vote for Lime-Support in Netbeans

The Netbeans-IDE already has PHPUnit support. It is possible to run the unit tests from the IDE and get the result shown in a pretty way. I opend a feature request at the netbeans tracker to support Lime too. I think Lime2  support should not be really difficult through the xUnit XML-Resultfile-Support of Lime2. If you like to have the feature in a future version of Netbeans just vote for it under: http://www.netbeans.org/issues/show_bug.cgi?id=175256

:-)

No tags

Oct/09

15

Colorize your Windows Console output

Update: The code-changes are included in symfony by now. If you use 1.3 or higheryou will not need to patch any symfony files.

If you are one of the developers, that is “forced” to use Windows on your development machine, you probably wish yourself a more comfortable console window. The windows one just missing all features I wish me for developing with Symfony. A good copy&paste, no colored output, no tabs… I know that many developers are using cygwin to get arround of such problem, but cygwin and I will never get the best friends…

Today I came across AnsiCon (http://adoxa.110mb.com/ansicon/index.html). This small utility helps the Windows commandline to understand ANSI-Color-Codes and other escape characters. The installation is pretty easy, just copy the ansi.dll and ansicon.exe in a folder of your machine (i.e. c:\ansicon). After that set the PATH-Environment-Variable in the system settings, add the ansicom path there. Afterwards start ansicon with “ansicon.exe -i”. This installs a registry setting. Thats it!

ANSI-Colors and escape characters are now interpreted correctly. But there is a problem for Symfony-Developers: The Symfony classes with Console output doesn’t output ANSI-Colors on Windows :-(

At the moment the only possibility is to change the Symfony Sourcecode. This is a bad thing. You never should change the framework sourcecode. Therefore I opened a ticket in the Symfony-Wiki (http://trac.symfony-project.org/ticket/7359). If you lin to have this function added to symfony just support this in the ticket.

If you like to test the colorization for yourself open the lib/vendor/lime/lime.php and change line421 from

if (DIRECTORY_SEPARATOR == '\\' ||
   !function_exists('posix_isatty') ||
   !@posix_isatty(STDOUT))

to

if (is_null(getenv('ANSICON')) && (DIRECTORY_SEPARATOR == '\\' ||
   !function_exists('posix_isatty') ||
   !@posix_isatty(STDOUT)))

When you call “symfony test:unit” you will get a result like the one in the screenshot:

console.png

The other file that needs to be changed is the  libn/commands/sfAnsiColorFormatter.class.php. There you need to change line 145 to:

return !is_null(getenv('ANSICON')) ||
  ( DIRECTORY_SEPARATOR != '\\' &&
      function_exists('posix_isatty') &&
     @posix_isatty($stream) );

That’s it! Now the symfony tasks (list, help…) will show their results in color :-)

No tags

Sep/09

29

Launched German Symfony User Group

I launched a new Symfony User Group for the german area Stuttgart, Ludwigsburg and Heilbronn. Everyon who is interessted can join us via http://symfony-usergroup-schwaben.mixxt.de. We will try to hold regular meetings in the future as soon as we have enough members.

So come on over and join us :-)

No tags

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

Aug/09

5

sfAmfPlugin 1.4.2

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

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

Jul/09

15

Looking for help for CuteFlow

CuteFlow is an open source PHP workflow management system. The current version is written in plain PHP. The codebase is pretty old and pretty pretty pretty ugly for current PHP standards. We are at the beginning of a complete rewrite of the system with Symfony but still maintaining the old version. The most work is done by myself, so I can need any help I can get. If you are interessted in helping there are a lot of areas you can help.

  • New website with symfony (layout is ready)
  • Writing documentation
  • Creating Screencasts
  • Developing

If you are interessted send me a mail to timo.haberkern@fantastic-bits.de.

No tags

Older posts >>

Theme Design by devolux.nh2.me