ED php framework :: Tutorial #2
Install the framework
The ED Framework has very simple installation. All you have to do is to set up first Apache + PHP + enable PHP modules:
curl, mcrypt and sockets. All these modules can be omitted as very specific classes rely on them.
See the previous topic for installing Apache and PHP.

For simplicity reasons we will suppose that you are planning to build a site called www.mysite.com 
and you prefer to keep your sites in directory "C:\websites" for Windows or "/websites" for Linux.
These directory paths are not obligatory and you can change them to whatever you want.

1. Download the framework and unzip it under C:\websites\mysite.com

2. Only Linux!!! Give read/write permissions to the following files and directories:

    chmod ugo+rw /websites/mysite.com/protected/log/error.log
    chmod ugo+rw /websites/mysite.com/protected/log/system.log
    chmod -R ugo+rw /websites/mysite.com/protected/persistent/
    chmod ugo+rw /websites/mysite.com/system/working/app.lock
    chmod -R ugo+rw /websites/mysite.com/public/www/system/widgets/
    chmod -R ugo+rw /websites/mysite.com/public/www/system/repository/

Note: ugo+rw gives rights to everyone, you may want to add rights only to a specific user.

3. Set the domain in httpd.conf or httpd-vhosts.conf

<VirtualHost *:80>
      ServerAdmin webmaster@mysite.com
      DocumentRoot "C:\websites\mysite.com\public\www"
      ServerName www.mysite.com
      ErrorLog logs/mysite.com-error_log
      CustomLog logs/mysite.com-access_log common
</VirtualHost>

That's all. Now you can adjust C:\websites\mysite.com\appconfig.inc and start placing your pages 
under "C:\websites\mysite.com\public\www". 



Directory structure explained
PROTECTED
This is the place, which you will use to store all your files, which have to be protected and not accessible via HTTP. May be some of the predefined folders will be unuseful for your site, just skip them. For every directory a PHP constant is defined, which has a value equal to the filesystem path of that folder. See Documentation/Global Constants.
protected/content Here we can place any kind of content we want later to access using "TContent::load".
protected/i18n Here we place the locale files, which support the multi-language versions of the site.
protected/lib Here we place all help classes and functions our pages rely on. All of them need to have extension .inc and the system will load them automatically.
protected/log There are 2 global functions - errorLog and systemLog. They log their output to system.log and error.log under this directory. If we turn ON $application->errorHandler->setLogToFile(TRUE), then the errors will go to error.log
protected/persistent There are 3 subdirectories inside - "app_state", "cache_state" and "tmp". Application level state methods use the 1st one and in case you set TCache to use the file system it will save it's state in the 2nd. The 3rd one is used by the "file upload" widget as a temporary storage.
protected/repository Global place for storing all javascript and css files our application is relying on.
protected/security Any kind of sensitive data.
protected/sql Here we place all our SQL statements. We access them using "TSqlStatement::sql" function.
protected/tpl Here we place some HTML or TEXT templates. We access them using "TPageTemplate::load" or "TContent::load".
protected/widgets All widgets are placed here
protected/xml Here we place any kind of XML files. Some of them can be accessed using "TDataSource::load".
protected/constants.inc Here we place all application constants.
PUBLIC
This is the place, which you will use to place all your pages divided by subdomains. For www.mysite.com the pages should be placed under "public/www". For admin.mysite.com the pages should be placed under public/admin and so on.
public/www Place all your pages for www.mysite.com here. Under this folder there is another folder named "system". It contains all HTTP visible assets the framework relies on - javascript, css, image files. If you decide to add another subdomain you have to copy this "system" folder in it as well.
SYSTEM
This is the place, which holds all the ED Framework classes. Normally you should never deal with it. There are only 2 things you can do:
  • Give write permissions to 1 file. See "app.lock" above
  • Create a cache copy of the framework
APPCONFIG.INC
This is the only place where the ED Framework can be configured. Database, error handling and pages, which require authorization are set up here. All xxx.php.script files must include it.