symfony
symfony forum
Home » support » symfony 1.0 » [Tutorial] My Second Project - Admin Generator  (5) 2 Vote(s)
[Tutorial] My Second Project - Admin Generator [message #21735] Thu, 15 February 2007 17:24 Go to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
Hi,

For anyone trying to follow the Admin Generator screencast, here is a ready-made file to get you started a bit easier.

All you need to do:

- install symfony the pear way.
- unzip the attached tgz file under your web root.
- edit 'config/propel.ini' and point the 'propel.output.dir' to your actual location.

You should have a working Admin Generator to play with right away. Then, you can start with customization from 05:15 of the screencast.

Note,

1. I change the sfdemo from the screencast to sfpear, just to show that the app name doesn't matter.

2. You need to create a mysql database named sfpear as well:

echo "create database sfpear" | mysql -uroot  --password
echo "GRANT ALL ON sfpear.* TO 'apache'@'localhost';" | mysql -uroot  --password

# then
symfony propel-insert-sql

php batch/load_data.php


3. The http user under FC is apache. Change the above 'apache' to your distro if it is different. E.g., in Debian, it is 'www-data'.

4. You don't need to setup VirtualHost or anything. Access them via:

http://localhost/sfpear/web/backend_dev.php/author
http://localhost/sfpear/web/backend_dev.php/category
http://localhost/sfpear/web/backend_dev.php/post

5. If you can't see the nice layout, check the 'web/sf' symlink.
The link currently is for FC; For Debian, link to /usr/share/php/data/symfony/web/sf instead.


[Updated on: Thu, 15 February 2007 22:23]


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: [Tutorial] My Second Project - Admin Generator [message #21764 is a reply to message #21735 ] Thu, 15 February 2007 22:16 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
Hi,

If you have any question for the OP, before asking here, please think twise if the question is actually regards the post.

I.e., I hope we can keep the thread a low trafic one so that people won't need to wade through pages and pages to find related information.

E.g., if you have problem installing symfony the pear way, please open and ask in a new theread.

thanks for your understanding. I guess we've all been through that situation before. Smile

[Updated on: Thu, 15 February 2007 22:17]


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: [Tutorial] My Second Project - Admin Generator [message #21822 is a reply to message #21764 ] Fri, 16 February 2007 17:16 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
sfxpt wrote on Thu, 15 February 2007 16:16

if you have problem installing symfony the pear way, please open and ask in a new theread.



After the issue is resolved, if you think it is related with this topic and will help people new to sf, please post a link from here. Further, a synopsis of the problem and solution is more appreciated.

thanks.

[Updated on: Fri, 16 February 2007 17:16]


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: [Tutorial] My Second Project - Admin Generator [message #21823 is a reply to message #21822 ] Fri, 16 February 2007 17:24 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
sfxpt wrote on Fri, 16 February 2007 11:16

After the issue is resolved, if you think it is related with this topic and will help people new to sf, please post a link from here. Further, a synopsis of the problem and solution is more appreciated.


Here is mine.

Background, it all begins here,
http://www.symfony-project.com/forum/index.php?t=msg&got o=20489&#msg_20489
I really thing symfony is a good project, but a good project also need good documentations for new-comers to get easy start. IMHO, this is not yet the case for symfony, It was a still a bumpy drive for me to get symfony started, and I've found many such cases in the forum history...

If you have any problem install sf, this might help.
My first symfony project Documentation enhancements
http://www.symfony-project.com/forum/index.php?t=msg&got o=20472&#msg_20472

I'm trying to follow the My first symfony project... I've noticed several places that could use some enhancements. I'll post them as I move along.

Why pick the sfdemo for the 2nd prject?
The "admin generator" doc does not go with the screencast
http://www.symfony-project.com/forum/index.php?t=msg&got o=20495&#msg_20495
Has anyone ever trying to follow the video?
Has the script for the video ever available somewhere?... no answer.

How not to use VirtualHost
http://www.symfony-project.com/forum/index.php?t=msg&got o=20787&#msg_20787
I don't want to setup the web server, let the application in the web/ root directory, but if I go through the pear installation method, I can't put my application in the web/ root directory any more...

The sfpear.step1.tgz contains meaningful lookup table drop-down
http://www.symfony-project.com/forum/index.php?t=msg&got o=20758&#msg_20758

- when it is intially generated, the html drop-down list of lookup table, eg author, was 1,
- right after custimization start, the html drop-down list starts to be meaningful, eg, showing actual author names instead of numeric 1.

the trick was not (clearly) explained in the vidoe, I'm just wondering what exactly the trick that enable it.

[Updated on: Fri, 16 February 2007 18:20]


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
icon2.gif  Re: [Tutorial] My Second Project - Admin Generator [message #21825 is a reply to message #21735 ] Fri, 16 February 2007 17:53 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
For people that turn to framework as complicated as symfony for help, I think 99.9% of time they need some authentication. So the next step in this tutorial is to add authentication capability. We'll add more fields to the author table, ie, login id, email, & phone etc, -- just for illustration purpose. The step1.tgz already contains meaningful lookup table drop-down, once the sfGuardPlugin is in, you'll see a working version of many to many relationship capability showcase in symfony.

The official doc is here,
http://www.symfony-project.com/book/trunk/06-Inside-the-Cont roller-Layer#Action%20Security

"Among the symfony plug-ins, the sfGuardPlugin extends the session class to make login and logout easy.":
http://www.symfony-project.com/trac/wiki/sfGuardPlugin

Initially, I had major problem just to make the sfGuardPlugin work. The symptom was, right after I turn the security on, I get blocked everywhere, even to login page. The whole analysis and solution is logged at
http://www.symfony-project.com/forum/index.php?t=msg&th= 5071&mid=21751.

Then, I was not able to

- when the user is not authenticated, redirect to the /login page.
- after the user has logged in, redirect to my Post/list page.

The solution is at
http://www.symfony-project.com/forum/index.php?t=msg&got o=22107&#msg_22107


After that was passed, there were still battles to fight. The sfGuardPlugin is so weired designed that is awfully hard to add those extra field, e.g. first name, last name, email, etc, that I almost wanted to give up the sfGuardPlugin. Check the details at
http://www.symfony-project.com/forum/index.php?t=msg&got o=20465&&srch=sfGuard#msg_20465

I am working towards a login system, to make things easier a bit.
I think the most easy way is to populate them beforehand with fixtures. This is how I did:

data/fixtures/fixtures.00.Category.yml
data/fixtures/fixtures.10.Users.yml
data/fixtures/fixtures.11.Author.yml
data/fixtures/fixtures.12.Admin.yml
data/fixtures/fixtures.15.User.Credentials.yml
data/fixtures/fixtures.20.Post.yml


I'm new to symfony (and quite new to php actually). the login system is what I can do currently. it is not a freely registration system which allows use to register themselves and populate the required fields themselves with validation.

Note that I didn't create the (default) sfGuardUserProfile class, but used the existing Author table for the user profile instead. If you have all the required info, then creating a login system this way is very simple -- just maintain the user login info and profile in a separated place and export/convert them into yaml fixtures, then load the yaml fixtures via:

symfony propel-load-data backend


BTW, it has been reported OK to use string-formed ids for the profile table, I tried to do that but didn't work. The full story is at:
http://www.symfony-project.com/forum/index.php?t=msg&got o=22122&#msg_22122

*Edit*:

Oh, that's because I was using symfony 1.0.0rc2, after upgrading to symfony 1.0.0, the numeric formed ids won't work any more. The string-formed ids works, which was included in the tgz file as data/fixtures/fixtures.11.Author.yml.070220.nok

[Updated on: Thu, 22 February 2007 19:56]


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: [Tutorial] My Second Project - Admin Generator [message #21826 is a reply to message #21735 ] Fri, 16 February 2007 17:55 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
For a newbie like me, the docs in the sfGuard wiki has mile long gaps between them.

Chanages to enable the sfGuard are logged at:
http://www.symfony-project.com/forum/index.php?t=msg&&am p;am p;th=5071#msg_21849

To Customize sfGuardAuth module templates, the wiki says:

Quote:


Customize sfGuardAuth module templates

By default, sfGuardAuth module comes with 2 very simple templates:

* signinSuccess.php
* secureSuccess.php

If you want to customize one of these templates:

* Create a sfGuardAuth module in your application

* Create a template with the name of the template you want to customize in your templates directory

* Symfony now renders your template instead of the default one



I've been trying to follow the above and fill the gaps within.

here is what I've did:

$ symfony init-module backend sfGuardAuth
$ cp plugins/sfGuardPlugin/modules/sfGuardAuth/templates/secureSuccess.php apps/backend/modules/sfGuardAuth/templates/
$ cp plugins/sfGuardPlugin/modules/sfGuardAuth/templates/signinSuccess.php apps/backend/modules/sfGuardAuth/templates/


I've tweaked all three templates under apps/backend/modules/sfGuardAuth/templates/, I.e., secureSuccess.php, signinSuccess.php & indexSuccess.php, and I've made the following changes:

$ head -5 apps/backend/config/routing.yml
# default rules
homepage:
  url:   /
  param: { module: sfGuardAuth, action: index }

$ cat ./apps/backend/modules/sfGuardAuth/actions/actions.class.php
<?php

require_once(sfConfig::get('sf_plugins_dir').'/sfGuardPlugin/modules/sfGuardAuth/lib/BasesfGuardAuthActions.class.php');

/**
 * sfGuardAuth actions.
 *
 * @package    sfpear
 * @subpackage sfGuardAuth
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
 */
class sfGuardAuthActions extends BasesfGuardAuthActions
{
  /**
   * Executes index action
   *
   */
  public function executeIndex()
  {
  }
}




But as the result, none of my customized templates are used. All that I want is that

- when the user is not authenticated, redirect to the /login page.
- after the user has logged in, redirect to my Post/list page.

The solution is
http://www.symfony-project.com/forum/index.php?t=msg&got o=22107&#msg_22107

[Updated on: Wed, 21 February 2007 15:39]


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
[Tutorial] My Second Project - Admin Generator + email sending [message #22126 is a reply to message #21825 ] Wed, 21 February 2007 00:38 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
The next step in this tutorial is sending emails. Trouble is, currently the official document is obsolete, and is pending to be updated. I am now looking at the swift mail plugin.


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: [Tutorial] My Second Project - Admin Generator + email sending [message #22197 is a reply to message #22126 ] Wed, 21 February 2007 17:38 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
well, the plugin seems to be a bit outdated.
http://www.symfony-project.com/forum/index.php?t=msg&th= 5137&goto=22116#msg_22116

While waiting for it to be updated, I'll go with the directly using the Swift Mailer.

tested fine so far, incorporating it into my demo project now...


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: [Tutorial] My Second Project - Porting to your distro [message #23066 is a reply to message #21735 ] Tue, 06 March 2007 00:08 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
sfxpt wrote on Thu, 15 February 2007 11:24

For anyone trying to follow the Admin Generator screencast, here is a ready-made file to get you started a bit easier.



The demo is made in FC5. If you trying it in other distros, e.g., Debian or Windoze, then it might not work:

$ /usr/bin/symfony

Warning: include(/usr/share/pear/data/symfony/bin/symfony.php): failed to open stream: No such file or directory in /usr/bin/symfony on line 39

Warning: include(): Failed opening '/usr/share/pear/data/symfony/bin/symfony.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /usr/bin/symfony on line 39


To port the demo to your distro, the solution is easy:

run

symfony init-project what_ever

in whatever directory, copy the generated config/config.php file and replace what's included in the demo.

That's it. That's the only file you need to change to port the demo to your distro.



http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
icon2.gif  Re: [Tutorial] My Second Project - email sending [message #23192 is a reply to message #22197 ] Wed, 07 March 2007 04:47 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
sfxpt wrote on Wed, 21 February 2007 11:38

The next step in this tutorial is sending emails. Trouble is, currently the official document is obsolete, and is pending to be updated.



it is now updated, just hasn't been published yet:

send email via sfMail
http://www.symfony-project.com/trac/browser/doc/branches/1.0 /cookbook/email.txt

comes with symfony v1, nothing extra need to be installed, and it works out of box! So no need tutorial/demo program any more.

[Updated on: Wed, 07 March 2007 04:50]


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: [Tutorial] My Second Project - Admin Generator [message #25013 is a reply to message #21825 ] Tue, 03 April 2007 17:31 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
I just found out that, the id in the fixtures yml files that is used for linking tables have to be lower case. If upper case characters are used, thing will break.

Check the details at:
http://trac.symfony-project.com/trac/ticket/1628


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
icon2.gif  [Tutorial] My Second Project - Image uploading [message #33917 is a reply to message #21735 ] Wed, 22 August 2007 15:28 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
sfxpt wrote on Thu, 15 February 2007 11:24


You should have a working Admin Generator to play with right away. Then, you can start with customization from 05:15 of the screencast.



Here are the screen shots for the original sfdemo project in the final stage:

1. how to enable image uploading, and "show photo" in list

index.php?t=getfile&id=371&private=0


[Updated on: Wed, 22 August 2007 15:35]


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: [Tutorial] My Second Project - Image uploading [message #33918 is a reply to message #33917 ] Wed, 22 August 2007 15:30 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
2. how the _photo.php is coded:

index.php?t=getfile&id=372&private=0


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: [Tutorial] My Second Project - Image uploading [message #33920 is a reply to message #33918 ] Wed, 22 August 2007 15:31 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
3. how to add a "all post" action in yml

index.php?t=getfile&id=373&private=0


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: [Tutorial] My Second Project - Image uploading [message #33921 is a reply to message #33920 ] Wed, 22 August 2007 15:32 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
4. the code for adding a "all post" action

index.php?t=getfile&id=374&private=0

[Updated on: Wed, 22 August 2007 15:32]


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: [Tutorial] My Second Project - Image uploading [message #33922 is a reply to message #33921 ] Wed, 22 August 2007 15:34 Go to previous messageGo to next message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
5. The validation yml

index.php?t=getfile&id=375&private=0


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Re: [Tutorial] My Second Project - Image uploading [message #33923 is a reply to message #33922 ] Wed, 22 August 2007 15:37 Go to previous message
sfxpt  is currently offline sfxpt
Messages: 339
Registered: January 2007
Location: Canada
Faithful Member
that's all.

[Updated on: Wed, 22 August 2007 16:21]


http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Previous Topic:date format, setlocale
Next Topic:propel-build-schema: incorrect conversion MtSQL boolean
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software