Nov 10
Digg
Stumbleupon
Technorati
Delicious

sfEmailTemplatePlugin 0.0.1 is released

Hi,

So first beta of sfEmailTemplatePlugin is finally released. Thanks a lot for all the guys who commented an initial post about this plugin (Eric, Gerald, COil and James). I must say this is really helpfull to read these warm words and it inspires me to work better.

This first beta does not include tag support for email template so far but it covers all the other declared functionality. Read Wiki page for futher details sfEmailTemplatePlugin.

Unfortunately, I wont be able to work on tags functionality in the nearest time so if someone will have a chance - everything is in his hands. There is already defined sf_tag_template table where email template tags must be stored.


Author: admin
Nov 08
Digg
Stumbleupon
Technorati
Delicious

sfEmailTemplatePlugin

We are going to publish soon new plugin which has a goal to simplify email templates management. It includes admin area where user is able to create and manage email subject/body (both html and text versions) and them system-wide constant values are generated for each email template and its elements, e.g. MYTEMPLATE_SUBJECT and MYTEMPLATE_BODY. This way emails can be easily added to mass mailer layers like swift mailer or so.

The other cool feature of this plugin is an ability to create and manage tags for email templates. So that user may define template with using of %NAME%, %DATE%, etc tags and they will be replaced with real values on the sending stage.

So it’s coming soon and let me know if you are interested in it or maybe have some good ideas or proposals.


Author: admin
Nov 06
Digg
Stumbleupon
Technorati
Delicious

Symfony automation idea

I already wrote about symfony automation stuff (and will keep writing about that for sure!). By the way, there were a couple of comments on this blog which showed that Symfony RAID is something that might be real bomb. But today I’d like to write about something simpler. This good idea visited me in the morning.
So that was an idea of symfony generator or plugin or maybe task that will parse specific pages.yml file from env/config/ and generate actions/templates/validate files based on this file. I imagine it the following way, pages.yml contains something like:

action1:
validate: yes // generate yml validation file for this action
error: yes // generate error success template for this action
action2:
template:
form:
field1: { name=Field1, type=text }
field2: { name=Field2, type=textarea }
submit: { type: submit }

This way there must be generated action file with 2 action functions, 1 action2Success.php template, 1 validation file action1.yml. As for me, this must be something that saves time for prototyping and early development. I’m sure it can be improved a lot with adding of templates themes, etc. The most important is that it can be done as simple generator and should not take too much time to have it done.

Would be interesting to hear the comments/proposals of community on this stuff.

Thanks


Author: admin
Nov 02
Digg
Stumbleupon
Technorati
Delicious

sfSupportPlugin

`sfSupportPlugin` is a symfony plugin that provides support functionality. It allows site visitors to create tickets and reply them. Plugin requires sfGuardUser in order to provide connectivity to user submodules. There is also admin module which allows to manage tickets and replies.

Install the plugin

symfony plugin-install http://plugins.symfony-project.com/sfSupportPlugin

Enable module in your settings.yml sfSupport, sfSupportAdmin

all:
.settings:
enabled_modules: [default, sfSupport, sfSupportAdmin ]

Clear you cache: symfony cc

Manage tickets

Access the tickets management module with the default route:

http://www.example.com/backend.php/sfSupportAdmin

Use support in your application

Use the following link to redirect user to support area:

<?php echo link_to(’Support’, ’sfSupport/index’) ?>

You’re done.


Author: admin
Nov 01
Digg
Stumbleupon
Technorati
Delicious

SymfonyLab statistics

SymfonyLab site is about a week online and I’d like to share some of our statistics for October and put here some other information related with that. So first of all bad news we had to turn off FeedBurnerSmith plugin because of symfony community’s blog was not able to retrieve our posts and our posts were not appear on community page. That’s why number of visitors in our FeedBurner’s box now is very small (it does not represent real number of subscribers which is almost 100 now). Good news we’ve got a few interesting comments and a lot of good words for what we are doing :-) Thanks guys for your support

Now lets talk about statistics, of course week is not enough to say about stable behaviour but generally it gives good picture. So during last days of Octored we’ve got 1606 unique visits and 12490 hits. Frankly to say we did not expect that. We’ve also got a few adsense clicks and earned about $5 which is small but enough to make a decision - so we’ve decided that we will donate 25% of adsense earnings into symfony’s development, in other words we want to invest into symfony because it makes our life easier.

Another statistics I’d like to share is that we’ve got 61% visits from Firefox browser and only 14% from IE (11% - unknown, all the others are Opera, Safari, Mozilla). Platforms from which we’ve got visitors -

Windows (73%)
Linux (12%)
Unknown (11%)
Macintosh (5%)

Interesting about visitor’s countries (only > 3%):

Romania (32%)
Unknown (19%)
United States (10%)
France (7%)
Netherlands (5%)
Germany (4%)

And the most interesting is search strings (only first 8):

symfony criteria - 8
symfony - 7
symfony eclipse - 4
wforms - 4
symfony form_remote_tag - 4
symfony sucks - 3
symfony chm - 3
symfony criteria join - 3

I could not believe that “symfony sucks” is something that can be searched but there is still someone that think so.
Thanks again and next coming will be promised symfony-based sites reviews, more plugins and real-life practices.


Author: admin
Oct 31
Digg
Stumbleupon
Technorati
Delicious

How to populate object_select_tag with your own objects

Sometimes you need to have an ability to show limited number of elements in your select objects or sort elements by name or so. I figured out that this feature was added to object_select_tag later so that not everybody knows about that. This feature’s name is ‘peer_method’ - effectively you create your peer method which returns objects which must appear in your object_select_tag. So here is the code for object_select_tag:

echo object_select_tag($domain, ‘getObjectId’, array (
‘related_class’ => ‘Object’,
‘peer_method’ => ‘getSortedObject’,
‘control_name’ => ‘object_id’,
‘include_blank’ => true,
));

and this must be put in your ObjectPeer.class.php:

static public function getSortedObject() {
$c = new Criteria();
$c->addAscendingOrderByColumn(TablePeer::NAME);
$rs = TablePeer::doSelect($c);
return $rs;
}

Interesting how this can be done in generator without re-writing of edit_form.php template. I suspect this can be done directly in generator.yml but never tried it. If someone has experienced would be good to know.

Thanks in advance.


Author: admin
Oct 30
Digg
Stumbleupon
Technorati
Delicious

Tricks with symfony .htaccess

I decided to put here a couple of .htaccess rules that may help you in your daily practice to save the time trying to get it working. Real .htaccess guru of course wont find it usefull but maybe someone will tell me thank you :-)

How to use Symfony on naked IP without domain name

Sometimes you dont have domain name but you would like to get your symfony project working. All you need is love, love, love and add the following line into your .htaccess

RewriteRule ^(.*)$ http://XX.XX.XX.XX/~accountname/index.php [QSA,L]

so full .htacces must look like this:

<IfModule mod_rewrite.c>
RewriteEngine On

# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /

# we skip all files with .something
RewriteCond %{REQUEST_URI} \..+$
RewriteCond %{REQUEST_URI} !\.html$
RewriteRule .* - [L]

# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f

# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteRule ^(.*)$ http://XX.XX.XX.XX/~accountname/index.php [QSA,L]
</IfModule>

How to get visitors redirected to WWW.

Sometimes you dont have domain name but you would like to get your symfony project working. All you need is love, love, love and add the following line into your .htaccess

RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

so full code must look like:

<IfModule mod_rewrite.c>
RewriteEngine On

# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

# we skip all files with .something
RewriteCond %{REQUEST_URI} \..+$
RewriteCond %{REQUEST_URI} !\.html$
RewriteRule .* - [L]

# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f

# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

and the last but not least thing

How to use Symfony along with the other software in the same directory

This one is a bit more tricky that the other ones but also nothing complicated. I think you may found this or similar information on symfony forum but here I collected what I have been really tried and made sure it’s working. So lets consider a using of popular CMS Wordpress along with Symfony project. So because of WP uses index.php file as a core we would need to rename symfony’s index.php file into somthing else, lets name it symfony-index.php and next step it to add the following code into .htaccess:

RewriteRule ^/blog/wp-admin/(.*)$ /blog/wp-admin/index.php [L]
RewriteRule ^/blog/(.*)$ index.php [L]
RewriteRule . /index.php [L]
RewriteRule ^(.*)$ symfony-index.php [QSA,L]

Full .htaccess must look like this:

<IfModule mod_rewrite.c>
RewriteEngine On

# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /

# we skip all files with .something
RewriteCond %{REQUEST_URI} \..+$
RewriteCond %{REQUEST_URI} !\.html$
RewriteRule .* - [L]

# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f

# no, so we redirect to our front web controller
RewriteRule ^/blog/wp-admin/(.*)$ /blog/wp-admin/index.php [L]
RewriteRule ^/blog/(.*)$ index.php [L]
RewriteRule . /index.php [L]
RewriteRule ^(.*)$ symfony-index.php [QSA,L]

</IfModule>


Author: admin
Oct 29
Digg
Stumbleupon
Technorati
Delicious

sfCaptcha documentation is updated

There were the major updates to sfCaptchaPlugin documentaation. Thanks a lot to crux_op for keeping this documentation page clean and up-to-dated.

I’d like to ask the community opinion on how this plugin should progress, i.e. which improvements you want to see in it.
What I’m thinking so far is about kind of skins for it, so it does not look so boring but it’s actually depends a lot on JpGraph as it’s the graphical library.


Author: admin
Oct 28
Digg
Stumbleupon
Technorati
Delicious

SimpleXML in Symfony

I thought I got crazy about it. I’ve discovered SimpleXML for myself and I felt in love with it.
I never though work with XML may become such simple and then… Then I thought I really hate SimpleXML coz it took out almost hour of my life.

So here is the situation I have a XML response like:

<elements>
<element>
<value1>XXX<value1>
</element>
<element/>
<value1>YYY</value1>
<element/>
</elements>

And I’m going to parse it and find out if there is element with value1 = XXX in my database..

So generally it looks like this:

$b = new sfWebBrowser();
$b->get(XML_SOURCE_URL);
$xmlstr = $b->getResponseText();
$xml = new SimpleXMLElement($xmlstr);
foreach ($elements as $e) {
$c = new Criteria();
$c->add(TablePeer::VALUE1, $e->value1);
$dom = TablePeer::doSelect($c);
}

It looks great and I was sure it MUST work great..
And what do you think I’ve got?

PHP Fatal error: Call to undefined method SimpleXMLElement::__toString() in C:\usr\php5\PEAR\pear\symfony\vendor\creole\common\PreparedStatementCommon.php on l
ine 596

Fatal error: Call to undefined method SimpleXMLElement::__toString() in C:\usr\php5\PEAR\pear\symfony\vendor\creole\common\PreparedStatementCommon.php on line 5
96

It’s fine. I’m quickly looking through symfony forum and find out this

where someones responses to someone:

you are probably trying to insert a simplexml objet into a string column.

i.e you are doing something like :
$this->feed = new SimpleXml($feedurl);
/*..*/
$this->save();

this can not work since simplexml has no toString method and you will have to do $this->feed->asXML()

But I’m not storing anything. Moreover, when I remove criteria stuff everything works fine, I can print out values but I can’t get connected to DB.

Well, after some time of investigating I figured out that correct code is:

$b = new sfWebBrowser();
$b->get(XML_SOURCE_URL);
$xmlstr = $b->getResponseText();
$xml = new SimpleXMLElement($xmlstr);
foreach ($elements as $e) {
$c = new Criteria();
$c->add(TablePeer::VALUE1, (string)$e->value1);
$dom = TablePeer::doSelect($c);
}

See the difference? Force type conversion to string. I’m disappointed.. I’m depressed.. I need some beer because I have not expected such bullshit may happen to me.

Have a great weekend guys!


Author: admin
Oct 26
Digg
Stumbleupon
Technorati
Delicious

Uml2Symfony

In previous post I wrote about Symfony2Exe stuff and now I’d like to bring a question of UML. I can’t say however how important is using of UML as I’ve never used it. Not because I dont know it but because the other dont know it. But as I figured out there is a tool which can be used to simply symfony development even if I’m the only person who is working on development process: Uml2Symfony

As it turns out from documentation you will need also ArgoUML software.

Here are the list of commands for Uml2Symfony:

uml2symfony-translate - which opens the design.uml file and generates schema files and plugins accordingly. A component in the UML diagram is translated into a symfony plugin, and the classes inside the component is added to the plugin schema file.

uml2symfony-crud-plugins - Which creates modules for each class in a component. Warning! This task does not yet test whether you have made any changes to the actions or templates, it overwrites what ever is in the plugin modules dir.

uml2symfony-load - Is a wrapper for propel-load-data. If you have set up databases.yml and propel.ini correctly but still get the error message: ”’No connection params set for propel”’ you can call this task which initializes propel correctly, adds lib and plugins/libs to autoload and then calls propel-load-data.

uml2symfony-all - Is not quite all :-). It calls uml2symfony-translate, propel-build-model, propel-build-sql, propel-insert-sql, uml2symfony-load, but excludes uml2symfony-crud-plugins.

It’s wonderfull! I guess it’s worth to start using ArgoUML and then e.g. generate plugins automatically. I’d say it’s good step towards Symfony Rapid Environment. Btw, I’m thinking about that these weeks. How about to integrate symfony with Uml2Symfony and WApache and have also some tools to draw quick pages layout (like Axure Pro has). As for me it should not be complicated to build up something like that on Delphi. And I’m sure that’s what Symfony community will really appreciate.

Makes sense?


Author: admin