Workshop - week 01

From mi-linux
Revision as of 06:59, 28 January 2009 by In9301 (talk | contribs)
Jump to navigationJump to search

Main Page >> Web Frameworks >> Web Frameworks - Workbook >> Workshop - week 01

1. PHP Info

One thing that is not mentioned in the Quick Start, which is often a good idea to do when you begin working on a new PHP server for the first time is uploading a PHP Info test file.

<source lang="php"> <?php // Shows all information, defaults to INFO_ALL phpinfo(); ?> </source> Browse to the page using your web browser, and hopefully you should get a page outlining the various configurations on the server. If all appears well with the PHP info file, we can move on.

Quick Start Zend Framework

We are going to be following the Zend Framework Quickstart tutorial to ensure we can get Zend to work properly from our University area.

Following how to set up a project structure, we need to create a directory structure in our personal space.

Using either an FTP client (FileZilla, WS-FTP, etc), or using a Shell prompt through putty, set up the folder structure outlined here.

2. Setting Up .htaccess

Following the instructions outlined here, set up the .htaccess file, and copy it to the QuickStart/public/ folder. There is a mistake on the page - you need to change this line from the tutorial.

# public/.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

Would become:

# public/.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /~<YourStudentNumber>/QuickStart/public/index.php [NC,L]

3. Bootstrap File

Set up QuickStart/public/index.php as outlined here. Then set up application/bootstrap.php.

Here there's a second mistake that we need to fix:

$frontController->setControllerDirectory(APPLICATION_PATH . '/controllers');

Would become:

$frontController->setControllerDirectory(APPLICATION_PATH . '/controllers');
$frontController->setBaseUrl('/~<YourStudentNumber>/QuickStart/public');
$frontController->setParam('useDefaultControllerAlways', true);

What we are changing here is we're saying "This is not using the root folder of the server; instead, we are using a sub-directory. As our accounts on mi-linux are set up as sub-directories, this is important. The final line of code is telling the front controller to use the default controller (Our IndexController) if a Controller we haven't got is requested. This means that if a user goes to a page we haven't set up, ( http://mi-linux.wlv.ac.uk/~in9301/QuickStart/public/thisPageDoesntExistAndWillRedirectToIndex ) they will see the index view instead.




References

http://framework.zend.com/docs/quickstart/

http://www.johnmee.com/2008/11/zend-framework-quickstart-tutorial-deploy-to-a-subdirectory-instead-of-web-root/