miércoles, 3 de noviembre de 2010

Installation Steps for sfDoctrineGuardPlugin

Steps to install the sfDoctrineGuardPlugin using Netbeans 6.9.x by downloading the package instead of installing it with PEAR.

Download and Installation

Download the correct version of sfDoctrineGuardPlugin, do not download the sfGuardPlugin which is for the Propel ORM.

1. On the sfDoctrineGuardPlugin page http://www.symfony-project.org/plugins/sfDoctrineGuardPlugin click on Download Package select a download directory (/Users/myuser/Downloads).
2. Open the Netbeans right click on the project select Symnfony>Run Commnad...
3. Select plugin:install task.
4. On the parameters field type the path to the downloaded file (for example: /Users/myuser/Downloads/sfDoctrineGuardPlugin-5.0.0.tgz)
5. Click on Run

During the installation I get severl errors like: PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /Applications/xampp/xamppfiles/lib/php/pear/PEAR/Registry.php on line 790 But the installation seems to work fine.

This process will register the plugin on the project configuration (myproject/Sources Files/config/ProjectConfiguration?.class.php) and copy the plugin to your plugins directory. Verify that the project configuration looks something like this

require_once '/usr/lib/php/symfony/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();

class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enablePlugins('sfDoctrinePlugin');
$this->enablePlugins('sfDoctrineGuardPlugin');
}
}

Verify that a directory with content is under myproject/Sources Files/plugins under the name sfDoctrineGuardPlugin.

Configuration

Table Creation and Data Loading

1. Copy the file myproject/Sources Files/plugins/sfDoctrineGuardPlugin/data/fixtures/fixtures.yml.sample to myproject/Sources Files/data/fixtures
2. Rename myproject/Sources Files/data/fixtures/fixtures.yml.sample to sfGuard_fixtures.yml
3. Open the Netbeans right click on the project select Symnfony>Run Commnad...
4. Select symfony doctrine:build-model
5. Click on Run
6. Select symfony doctrine:build-sql
7. Click on Run
8. Select symfony doctrine:insert-sql
9. Click on Run
10.Select doctrine:build task.
11.On the parameters field type --all --no-confirmation --and-load
12.Click on Run

This will drop the existing tables recreate them, create the sfGuardPlugin tables and load the fixtures from the application and from the sfGuard_fixtures.yml.
Enabling Modules

This configuration assume you have two applications frontend and backend. The frontend will only authenticate and the backend in addition to authentication will have access to create users, groups and permissions.

Backend Configuration

1. Open the myproject/Sources Files/apps/backend/config/settings.yml
2. Find the enabled_modules, if it does not exist create it, add the sfGuardGroup, sfGuardUser and sfGuardPermission. It should look like this:

all:
.settings:
enabled_modules: [default, sfGuardAuth, sfGuardGroup, sfGuardUser, sfGuardPermission]

3. Change the default login and signin modules. Adding this:
    .actions:
login_module: sfGuardAuth
login_action: signin

secure_module: sfGuardAuth
secure_action: secure
4. Save the file.
5. Open the file myproject/Sources Files/apps/backend/config/filters.yml
6. Add the following before the security filter:
    remember_me:
class: sfGuardRememberMeFilter

security: ~
7. Save the file.
8. Open the file myproject/Sources Files/apps/backend/lib/myUser.class.php
9. Change to myUser to inherit from sfGuardSecurityUser instead of sfBasicSecurityUser

class myUser extends sfGuardSecurityUser
{
}

10. Save the file.
11. Open the file myproject/Sources Files/apps/backend/config/security.yml
12. Change the is_secure variable to true:

default:
is_secure: true

Test the access to the sfGuardUser accesing the following url: http://127.0.0.1:9091/backend_dev.php/sfGuardUser Change the host 127.0.0.1:9091 to your host.

Frontend Configuration


1. Open the file myproject/Sources Files/apps/frontend/config/settings.yml
2. Find the enabled_modules, if it does not exist create it, add the sfGuardAuth. It should look like this:

all:
.settings:
enabled_modules: [default, sfGuardAuth]

3. Change the default login and signin modules. Adding this:

.actions:
login_module: sfGuardAuth
login_action: signin

secure_module: sfGuardAuth
secure_action: secure

4. Save the file.
5. Follow steps 5 through 12 of the Backend Configuration for the frontend application.

3 comentarios:

  1. No puedo hacer funcionar el remember, estoy siguiendo los pasos que indicaste, pero no hay caso.

    ResponderEliminar
  2. Verifica que el brower tenga la opción de aceptar cookies habilitada.

    ResponderEliminar
  3. Segui todos los pasos pero aun no anda el recordar y el navegador tiene la opcion de aceptar cookies, alguna otra sugerengia? desde ya muchas gracias

    ResponderEliminar