Nov 24
Digg
Stumbleupon
Technorati
Delicious

Quick note about deleting records in Symfony/Propel

Just a quick note about deleting records in Symfony/Propel.
I’ve tested it both in symfony 1.2.x and symfony 1.0.x and got the same result.
So when you try to delete all records from table this way:

1
2
$c = new Criteria();
$rs = TablePeer::doDelete($c);

nothing happens but when I tried to add any dummy criteria to it like this:

1
2
3
$c = new Criteria();
$c->add(TablePeer::ID, 0, Criteria::GREATER_THAN);
$rs = TablePeer::doDelete($c);

it deleted all records like expected. Maybe I’ve missed something but looks like not logical to me.

If you want to try it yourselves here is sample of batch script:

1
2
3
4
5
6
7
8
9
  require_once(dirname(__FILE__) . '/../config/ProjectConfiguration.class.php');
  $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'dev', true);
  sfContext::createInstance($configuration);
 
  $databaseManager = new sfDatabaseManager($configuration);
  $databaseManager->loadConfiguration();
 
  $c = new Criteria();
  $rs = TablePeer::doDelete($c);

Author: admin
Nov 07
Digg
Stumbleupon
Technorati
Delicious

OpenEats review

1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 4.67 out of 5)
Loading ... Loading ...

This time we’ve decided to review open-source Open Eats Project “an open source recipe/meal planner that can be accessed by anyone across the Internet much like other commercial sites”:

http://www.openeats.org/

This is not only web-site though but also symfony 1.0.x driven project available for downloading.
Does not look like project is actively evolving, last posts in blog is dated by this summer (there was mentioned that 2nd version is planning which would work with symfony 1.2). But even though it’s pretty much ready for using. So basically it’s great source for self-learning. The project is sharing as bundled with whole symfony framework and there is detailed instruction about installation. Of course installation itself is not user-friendly (and comments at the bottom just proves that. It’s not symfony problem but pretty major problem of developing some kind of 3rd party tool which would simplify running of symfony driven projects for end-users. We already wrote about this problem some time ago).

But at this project we see in first time some kind of “install” tool for symfony project – it’s located in /web/setup folder – non-symfony script which asks for db/app settings and write them into symfony conf files.

Another interesting thing in Open Eats Project – it uses Zend Lucene for search feature.

Code is pretty well formatted and accurately written so anyone interested can easily understand in which modules what to look for.

A few plugins are using there which we never used, e.g. sfEventCalendarPlugin, sfPagerNavigationPlugin so was interesting to look on them (for symfony 1.0.x though).

We did not like that all database stuff is located in big config/schema.xml file. As for us, it’s preferably to keep db logic in separate plugins which would give this project extra value as those plugins could be re-used in another projects (e.g. user management related stuff), etc.

Another note it’s not actually community (main page of site states “Website community to shares recipes”). It’s rather “multiuser recipes management tool” :-)

But even though if you are symfony 1.0.x beginner (is there still any who start learning symfony with 1.0.x ? :-) ) – it’s worth to look into this.


Author: admin
Oct 31
Digg
Stumbleupon
Technorati
Delicious

Postcrossing symfony-driven site review

1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 4.20 out of 5)
Loading ... Loading ...

Today we’ve randomly selected for the review this symfony-driven site (mentioned in list of applications developed with symfony symfony sites):

http://www.postcrossing.com

So first of all it has simple but cool idea of postcards sharing. Site works fast, has clean and simple design and navigation w/o any noticeable bugs or disadvantages. Blog area is implemented using general site engine (we can’t state 100% though that it’s symfony-driven site b/c the only thing we found which reminds symfony framework is multilevel urls like /user/symfonian/gallery).

Forum area is driven though with XMB forum software which is a bit outdated and did not have updates since 02/28/2009. There must be created bridge between main “symfony” site and forum engine.

There were a few other things we’ve learned from this site for ourselves.

First of all we’ve found out from code that it uses unusual adsense inclusions and investigated that it’s because it uses “Google Ad Manager” to inject ads. It’s another one cool google service which we’ve heard about but only today had a chance to look into it more closely.

The other thing is ajax-driven live updates in style of popular nowadays “live search”, it appears when you login to user area under “What is happening now?”, here is the code which implements it and with slight changes you can use it for your own purposes (e.g. twitter like live updates, etc):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
 
<div id="liveEvents" style="overflow: hidden; height: 18em; width: 31em;"></div>
 
<script type="text/javascript">
//<![CDATA[
Effect.ScrollVertical = Class.create();
 
Object.extend(Object.extend(Effect.ScrollVertical.prototype, Effect.Base.prototype),
{
	initialize: function(element)
	{
		if(typeof element == "string")
		{
			this.element = $(element);
			if(!this.element)
			{
				throw(Effect._elementDoesNotExistError);
			}
		}
 
		var options = Object.extend({
			from: this.element.scrollTop || 0,
			to:   this.element.scrollHeight
		}, arguments[1] || {});
 
		options.to = options.to == this.element.scrollHeight ? options.to : options.from + options.to;
 
		this.start(options);
	},
 
	update: function(position)
	{
		this.element.scrollTop = position;
	}
});
 
var requests = 0;
var events = [...];
var lastId = 5926263;
var pullInterval = 30;
 
for($i = 1; $i < 8; $i++) {
    if (events.length) {
        printEvent(events.pop(), false);
    } else {
        break;
    }
}
 
startFetcher();
 
 
 
/* pullEvents(); */
 
function updateJSON(request, json) {
	json.each(function(txt){
				events.unshift(txt);
				lastId = Math.max(lastId, txt[0]);
			  });
}
 
function printEvent(eventToAdd, highlight) {
	spanId = 'event-' + eventToAdd[0];
	new Insertion.Bottom('liveEvents', '<div class="liveEvent"id=\"' + spanId + '\">' + eventToAdd[1] + '<\/div>');
	new Insertion.Bottom('liveEvents', '');
 
	if (highlight) {
	   new Effect.Highlight(spanId, {duration: 4});
	}
	new Effect.ScrollVertical('liveEvents', { });
}
 
printer = new PeriodicalExecuter(
			function() {
				if (events.length) {
					printEvent(events.pop(), true);
				}
			},
			3);
 
function pullEvents() {
	new Ajax.Request('/liveEvents/getLast',
					 { 	asynchronous:true,
						evalScripts:false,
						method:'get',
                      	parameters:'lastEventId=' + lastId,
						onComplete:function(request, json) {
									  updateJSON(request, json)
								   }
					 }
	);
}
 
function startFetcher() {
	fetcher = new PeriodicalExecuter(
				function() {
					if(events.length < 7) {
						requests = requests + 1;
						pullEvents();
					}
					fetcher.stop();
					if (requests < 6) {
						pullInterval = pullInterval + 10;
						startFetcher();
					}
				},
				pullInterval);
}
//]]>
</script>
</div>

The other thing which worth to mention here is site urls, until now we did not see good enough symfony plugin which would automatically generate clean SEO proven route-to-page.html URLs.
Obviously, anyone may use powerful symfony route mechanism but it always take time to go through each URL and make them look better way. Ideal solution would be some kind of plugin which would generate URLs based on some pattern like this route-to-page.html

Wish you guys all the best with this site, good job!


Author: admin
Oct 24
Digg
Stumbleupon
Technorati
Delicious

Sf Plugins Reviews

One of the features we were thinking about is sf plugins reviews page.

Unfortunately, what they have on native symfony site is far from ideal, e.g. when you’d try to search for sf 1.0 doctine plugins:

http://www.symfony-project.org/plugins/filter?filter[sf_1_0]=on&filter[doctrine]=on&filter[category_id]=&filter[name]=

You get some strange results.

First of all there will be included plugins for sf 1.2 and 1.1 as well.

Also there are some plugins ready for using but you can read in documentation “add geocoding possibilities to existants models in a symfony project using doctrine. But it’s not yet implemented” :-) So you never know if it’s ready or not?

In Doctrine results we have even found a few of our plugins which we developed for Propel only (http://www.symfony-project.org/plugins/sfConstPlugin, http://www.symfony-project.org/plugins/sfSettingsPlugin)

We are not trying to replace/fix anyhow sf native site plugins page though. Here we just want to inform about cool and not very cool existing sf plugins. And we’ve decided to add “reviews” section in main menu of our site. We plan to include there not only plugins reviews though but also symfony-driven sites reviews or other symfony-related tools (e.g. IDE which supports symfony ,etc). You can also use 5-star voting system to rate for each plugin or site which we will write about.

The first plugin we’ve decided to give a try is sfUploadManagerPlugin.

If you would like to participate and provide us reviews for the other plugins and sites (like the ones you created) we happily publish those reviews as alternative vision.

Together we are getting stronger!


Author: admin
Oct 24
Digg
Stumbleupon
Technorati
Delicious

sfUploadManagerPlugin

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 1.00 out of 5)
Loading ... Loading ...

The `sfUploadManagerPlugin` manage uploaded files in a database. Usefull with swfUpload or equivalent to be able to retrieve all file informations (original filename, size, mime type, uploaded date …).

http://www.symfony-project.org/plugins/sfUploadManagerPlugin

Sounds like interesting plugin but luck of information make it less worth than it could be.
So first of all it refers to the other symfony plugin swfUpload which uses flash/javascript library swfUpload for multiple files upload. Important to mention here – sfSWFUploadPlugin is only sf 1.0 compatible (at least that’s what mentioned in their readme). Therefore it’s hard to believe that sfUploadManagerPlugin which is sf 1.2 only compatible will work with sfSWFUploadPlugin which is for sf 1.0 only. The other bad news is sfSWFUploadPlugin has never updated since Jun 2008 while swfUpload lib had a few major releases since that time (last one was in March 2009).

We’ve decided to verify if there is never version of sfSWFUploadPlugin in SVN which would work with sf 1.2 but no luck, last update was year ago.

So our question is how could we use sfUploadManagerPlugin? Did anyone have luck with it?
Because actual idea behind of this plugin is wonderful.


Author: admin
Oct 17
Digg
Stumbleupon
Technorati
Delicious

Our community is growing, what’s next?

Dear SymfonyLab user,

We are happy to say that our community is quickly growing. Our site is not young we actually started to write about symfony and symfoniacs almost from the beginning of symfony era and since that time we keep informing symfony world about efficient using of this framework, publish own plugins, review symfony-driven sites. Our statistics says that in less than 2 years we’ve got strong and responsive community – great symfony developers who are reading and commenting our posts and vote for interesting symfony-related articles on corank service:

And at this point we think “where should we go now”? Would we add more community features or something that would add more value for our members? That’s where we really need your help, please leave response in comments so we can use that for our next planning. For instance, google friend connect is useful but it does not really allow users to communicate between each other, so probably it’s time to replace it with something else? If you still want to see here “google connect”, how exactly you use it?

Also we are planning to add “symfony plugins” review tool soon so everyone may write there comment and rate for existing symfony plugins. This way symfony plugins page wont be only source of information about plugins (right now it looks more like big storage with little information mostly only basic usage and installation).

We are really interested to hear what you’d like to see on this site in future.
Together we are stronger! :-)


Author: admin
Oct 10
Digg
Stumbleupon
Technorati
Delicious

Ok, so Doctrine.. Part 2

As we announced in our previous post we’ve decided to start using Doctrine instead of Propel.
The first steps in this direction are not about starting the new project though. We would like to see how simple would be to replace Propel with Doctrine in very simple project (like 2-3 simple DB tables).

It’s good that this process is already started and some steps are described in this Wiki article:

http://trac.symfony-project.org/wiki/ConvertingPropelProjectToDoctrine

But honestly not everything looks so cloudless. We were awared that Doctrine uses different schema syntax but it’s getting painful when you need to generate schema from existing DB. So if you have project with schema files described in plugins (e.g. sfGuardPlugin, etc) – you’ll have to generate new schema for Doctrine from existing DB and then slice this schema.yml (notice that Doctrine uses for it confiig/doctrine/schema.yml not confiig/schema.yml) into separate schemas for each plugin manually. Agree that if you have big project with lot of plugins this will be tricky.

So don’t forget to look into the Doctrine schema syntax before you’ll start doing that, e.g. here:

http://www.symfony-project.org/blog/2008/06/16/getting-started-with-doctrine-and-symfony-1-1

We are continuing to look into migration of existing project procedure and will keep you up-to-dated.
So far popular message for our command:

./symfony doctrine:build-all-load –no-confirmation

is

>> doctrine creating databases
>> doctrine generating model classes

No yml schema found in /www/project/cache/tmp, /www/project/config/doctrine

We have doctrine schemas described in plugins (not in /config/doctrine), but it’s strange anyway. In Propel we used to use this approach – all DB schemas were defined in separate plugins. Are we forced to add something to main doctrine/schema.yml (so far the file is empty)? I guess no but don’t see the answer yet.


Author: admin
Oct 03
Digg
Stumbleupon
Technorati
Delicious

Ok, so Doctrine..

Eventually, when Doctrine is officially selected as default ORM for symfony 1.3 we’ve decided that it’s time to use Doctrine. We knew all Doctrine’s advantages before but we used Propel from the very beginning of symfony and it’s actually sad to understand that Propel lost this war.

The biggest reason why it’s not fun to stop using Propel – most of Symfony plugins are written for Propel not for Doctrine. It was great to figure out that new Doctrine supports extensions (and there 5 extensions ready):

http://www.doctrine-project.org/extensions

But it’s obviously too small for the quick start. We are planning to start migrating of our most popular plugins to Doctrine though. Let it be one more brick into the great wall :-)

Ok, so Doctrine…


Author: admin
Aug 30
Digg
Stumbleupon
Technorati
Delicious

Using git for symfony projects

Hi,

If you finally decided to use version control software for your current symfony project this small article is for you. We use git and want to share some information about it with you.

So first of all you’ll have to install it:

1. wget http://kernel.org/pub/software/scm/git/git-1.6.4.1.tar.gz (of course number of version most probably will be changed so use git-x.x.x.x.tar.gz)
2. tar xzf git-1.6.4.1.tar.gz
3. ./configure
4. make
5. make install

Please use the following use(r)ful sources about git to know what to do with it now:

http://www.kernel.org/pub/software/scm/git/docs/everyday.html
http://www.spheredev.org/wiki/Git_for_the_lazy#Start_your_project
http://progit.org/book/
http://www.ibm.com/developerworks/web/library/wa-git/index.html
http://www.ibm.com/developerworks/web/library/l-git-subversion-1/index.html

Now b/c of you use it for symfony project you’d have to use the following simple script which we found in other article (please see here for full source):

I forgot numerous time to do a “./symfony clear:cache” after a “git pull”. Here is 2 easy steps to do it automatically:

Step 1: Create a file .git/hooks/post-merge which contains:

#!/bin/sh
#
# An example hook script that is called after a git pull is made
# To enable this hook, make this file executable.

# simply do a ./symfony cc after each git-pull
exec “$GIT_DIR”/../symfony cc

Step 2:Then make it executable

chmod +x .git/hooks/post-merge

When you do a git-pull, it will do a “./symfony cc”

And here are some other sources regarding using of git with symfony projects:

http://iamgraham.net/blog/sane-pre-commit-hooks-for-symfony-git
http://shout.setfive.com/2009/03/22/git-ignores-and-symfony/

Have a fun!


Author: admin
Aug 23
Digg
Stumbleupon
Technorati
Delicious

A note on approach to communicate with multiple databases in symfony

Pretty usefull article:

http://www.phpcult.com/blog/2009/08/talking-to-multiple-databases-with-symfony-1-2/

It’s only for propel though, interesting if similar approach would work for doctrine as well.

Here is the reason why Vidyut Luther had to use multiple databases:

I can’t just extend the existing application for reasons we don’t need to get into, but I do need to interface with the data, since the existing app doesn’t really have a nice way to handle a SOA, or share data easily, my next best option is to talk to the original app’s db.

But I guess the same will work for case if you need one backend and multiple databases (see our older article regarding it for symyfony 1.0.x: http://www.symfonylab.com/one-backend-many-sites/


Author: admin