Mar 29
Digg
Stumbleupon
Technorati
Delicious

Keep your projects up-to-dated. Step 1

Not sure how about you but I’ve been working with symfony 0.6.3 during quite a long time. I woked up one morning and said to myself – hey you need to upgrade. So I wrote before about the way of warrior – how did I upgrade my symfony 🙂

And the next related question is what should I do with my old projects. Sure thing I could have 2 symfony installations and sure thing it’s not neccessary to upgrade your projects. But.. If you have time and willing – why not?

First of all please pay your attention to a wonderfull wiki article: http://trac.symfony-project.com/trac/wiki/HowToUpgradeToLatestBeta

But in my case I’d preffer to build up my old projects from scratch and probably implement the features which propose newer symfony version.

So lets the war begin!

I did the commands:

symfony new project

symfony app frontend

symfony app backend

Of course, I want to use the latest sfGuardPlugin (I never used it in my projects before, so that’s a good chance to taste it)

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

The next step is how to be with my DB? Older symfony 0.6.3 did not support YML format.
You can build it up automatically. Go there and modify a couple of lines:

/config/propel.ini

propel.database.createUrl = mysql://userdb:[email protected]/

propel.database.url = mysql://userdb:[email protected]/dbname

and now run this command:

symfony propel-build-schema

Yuppee! You have your schema.yml in config/ folder. Sure thing you would need to modify it a bit to make it more readable but lets leave it for now.

We have installed sfGuard plugin. So lets prepare it for using with our project and feed it up with at least admin/admin account:

symfony propel-build-all

symfony propel-load-data backend

Now go to the following files and modify them a bit (I promise it will be really fast!):

/apps/backend/lib/myUser.class.php:

class myUser extends sfGuardSecurityUser

/apps/backend/config/factories.yml

all:

security_filter:

class: sfGuardBasicSecurityFilter

/apps/backend/config/routing.yml

sf_guard_signin:

url: /login

param: { module: sfGuardAuth, action: signin }

sf_guard_signout:

url: /logout

param: { module: sfGuardAuth, action: signout }

sf_guard_password:

url: /request_password

param: { module: sfGuardAuth, action: password }

/apps/backend/config/settings.yml:

all:

.settings:

enabled_modules: [default, sfGuardGroup, sfGuardUser, sfGuardPermission, sfGuardAuth]

.actions:

login_module: sfGuardAuth

login_action: signin

secure_module: sfGuardAuth

secure_action: secure

/apps/backend/config/security .yml:

is_secure: on

So you have your backend protected and moreover you have ready management UI for users/groups/permissions:

http://domain.com/backend.php/sfGuardUser

http://domain.com/backend.php/sfGuardGroup

http://domain.com/backend.php/sfGuardPermission

That’s all for today folks! Thanks for your comments. I’ll be waiting for newer ones.


Author: symfonian

1 Comment(s)

Marc
March 29, 2007

It’s nice to have a simple set of steps for implementing sfGuard, thanks. By the way, I recommend using some kind of syntax highlighter so your PHP and YML code is more easier to read. (now it blends in with the rest of the posts so it’s kinda hard to read).

Comments RSS TrackBack Identifier URI

Leave a comment