Symfony

AJAX request with Symfony sfBrowser in Lime functional test

1
Hello Symfonians!
While doing functional tests for my current Symfony application I needed to make AJAX call to one of my project endpoint.
I have found that not Lime or sfBrowser have this ability out of the box.
So if you need to make AJAX request from your Lime functional test you need do the following in your test:
<?php
include(dirname(__FILE__) . '/../../bootstrap/functional.php');

$browser = new sfTestFunctional(new sfBrowser());
$limeTest = $browser->test();

$browser->setHttpHeader("X-Requested-With",	"XMLHttpRequest");

$browser->post('/ajax/uri', array('param_name' => 'param_value'))->
        with('request')->begin()->
        isParameter('module', 'someModule')->
        isParameter('action', 'someAction')->
        end()->

        with('response')->begin()->
        isStatusCode(200)->
        end();
?>
The key point is in the headers, you send to the server:
$browser->setHttpHeader("X-Requested-With",	"XMLHttpRequest");

Symfony sfAssetsLibraryPlugin assets resize script

2

Hi there!

I’d like to share with this pretty simple script with you, hope it will save you few minutes.

You guys who familiar with this Symfony plugin for assets management probably know that it uses sfThumbnail plugin for making thumbnails of image assets.
sfThumbnail has configuration in app.yml and it looks like:

all:
  sfAssetsLibrary:
    upload_dir:       media                  # Asset library root, under the web/ dir
    check_type:       false                  # Set to true if you want to restrict the type of assets
    types:            ['image']  # Accepted asset types if check_type is true
    thumbnail_dir:    thumbnail              # Where the image thumbnails are stored
    use_ImageMagick:  false                  # Set to true if you have the convert command
    thumbnails:                              # Name and size (in pixels) of the thumbnails created at upload
      tiny:                                 # Displayed in the list page
        width: 70
        height: 70
      small:                                 # Displayed in the list page
        width: 100
        height: 100
        shave: false                          # Cut strips to constraint the image size
      middle:
        width: 200
        height: 200
      large:                                 # Displayed in the details page
        width: 450
        height: 450
      original:                                 # Displayed in the details page
        width: 800
        height: 800
    search_pager_size: 20                    # Number of resuts per page
    mass_upload_size:  5                     # Number of file upload controls displayed in the mass upload form

This is cool but when you have your project up and running and decided to add new type of thumbnail (for instance name it ‘big’)

      big:
        width: 400
        height: 400
you’ll have a problem: you need to resize all old images according to new thumbnail type.

(more…)

From Symfony to Grails!

6

Few weeks ago I started learning Grails framework.

For me this is new world but it smells like Symfony sometimes – almost the same approaches with domain (Symfony: model) management, CRUD generator (Symfony: Admin generator) here excites as much as in Symfony.

“Leaving” PHP world for Groovy-Grails-Java was quite hard on start and I still stuck in researches. But I have smart enough guru in the stretched hand distance, please let me introduce Alex, The Grails Guru.

If you are Symfony developer you’d love this framework. You’ll see there similar things you’ve used to use in Symfony:

  • mvc: domain classes + controller classes + view in GSP pages
  • routing: you can define any route rule in a special routing construction
  • configuration: there no any YAML configuration files but .properties files instead
  • partials: are also present in Grails like includes
  • and so on, I can’t remember on a spot. I’ll be adding this list with new features.

BUT started developing Grails applications you’ll get all Java development advantages:

  • Continuous integration development
  • Maven 2, dependencies management (management of so many libraries becomes easiest task)
  • Reliable, useful  and fast IDE IntelliJ IDEA (you can try it for 30 days)
  • Professional TDD (saying the truth, not all PHP developers using it, but in Java world things become better)

On other hand you can try work with Grails on Ubuntu Linux, it is faster then Windows machines.

I’ll be posting my achievements and research results here while learning this amazing tool.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes
Go to Top