Sunday, April 17, 2011

Internship — Week 6

For my last week of internship (6th week), I got to do the followings:
  • Learned more about Symfony
  • Built more things with Symfony
  • Learned more about Subversion (User Administration)
  • Setup staging / testing environment for up-coming campion website
  • More game playing (I mean testing)
  • Slicing up mockups done in Adobe Photoshop into web images

Symfony: Getting the hang of generating data model, forms, filters, and modules in Symfony. Here are the general steps I have developed:
  1. Define tables in database
  2. Reverse engineer database table definitions to /config/schema.yml
    $ php symfony propel:build-schema
  3. Generate the necessary models
    $ php symfony propel:build --model
    Note: If you do not want to regenerate all the models of all the tables in the database, make sure you trim /config/schema.yml. Though, don't forget to save a copy of it before trimming it and restoring it after these steps.
  4. Generate the necessary filters
    $ php symfony propel:build --filters
  5. Generate the necessary forms
    $ php symfony propel:build --forms
  6. Generate the necessary modules
    $ php symfony propel:generate-module \
    --non-verbose-templates --with-show \
    <appName> <moduleName> <modelName>
    Where
    <appName> = the name of the application
    <moduleName> = the name of module for the application
    <modelName> = the name of the model for the module
    Note: If you don't know already, the black slash ("\") indicates the command continues on the next line (UNIX / Linux).
    Repeat this until all modules are generated.
  7. If administrative modules (pages) are required, generate them by
    $ php symfony propel:generate-admin \
    --module=<adminModuleName> <appAdminName> <modelName>
    Where
    <adminModuleName> = the name of the administrative module for the application (to make things easier, use the same name as the non-administrative module if they are related)
    <appAdminName> = the name of the application for administrative purposes (assuming this is related to the non-administrative application, then just suffix that name with "admin" or "_admin")
    <modelName> = the name of the model for the administrative module
    Repeat this until all administrative modules are generated.

Subversion: If Subversion is configured to use HTTP, it is still possible to restrict access by user/password login. The following discussion is based off Apache web server.

As part of Apache configuration for Subversion you can direct Apache to a specific user/password file. Typically this file ends with .passwd. But storing user/password in plain text is pointless. No need to worry. There is a command you can use to create user and encrypted password entries in this file. Though you need to have root / administrative access to the server.

Here is the command:
$ sudo htpasswd -mb <userPasswordFile> <user> <password>
Where
<userPasswordFile> = fully qualified (full path) name of the user/password file configured in Apache for Subversion.
<user> = user id to be used for login
<password> = plain text format of the password

How does this encrypts the password? It's done by the option -m (MD5 encryption method). If you would like to use another encryption method, change -m to the corresponding option (-d: CRYPT and -s: SHA).

Option -b tells the system to use the password specified in the command line. Otherwise, you will be prompted to enter the password.

To delete a user from the file, execute the following command:
$ sudo htpasswd -D <userPasswordFile> <user>