public PHP library pPHPskel

pPHPskel

pPHPskel is a small applications which enables you to create the basic setup for your project, which will be using the pPHPlib. pPHPskel will create the suggest directory tree structure and configure file path and web path information as well as database connection settings. This is achieved by first editing a configuration file, called parse.conf. The 'parse' will then read this file and create the project settings based with values give in this file.

Download and install

The pPHPskel can be obtained the same way as the pPHPlib, thus via the zipped and tared source files or via CVS. Locations are the same as given above for the pPHPlib.

Installation is just unzipping the files to a location where you have write acces to (normally your home directory). After unzip, change to the directory (pphpskel) and there you find parse.conf, the central config file.

The config file

As already mentioned above, the config file is called parse.conf. You can find it in the base level of the pPHPskel tar. This file has to be edited in order to create your base project. Information like name of the project, location of the project on the server, http paths and database connect information has to be given. The file itself is very well documented, so if you need information on a particular setting, parse.conf might the place where you you will find it. For some more elaborate settings and principles however please see below.

Production only or full scale development

pPHPskel gives you the possibility to create a production only or full scale development project. The first is, that config files and settings are only created for the production environment. This might be the prefered setting for very small project or one-man proejcts. In a 'full scale' project, most include files consist of three parts: the settings for the production environment, the ones for the test environment and the settings for the development environment. This will be the prefered setting in large project with multiple developers working on and if every change to the project first has to be reviewed by the 'customer'. A central file called version.inc.php will then determine which sections of the files will be used.

Include comments or not?

The project files can be created with additional comments and information added to them. This normally is a very good idea, esp. for the inexperienced users as this gives indications of what the various settings are about. However, for experienced users this information might clutter up the file, even more so as the name of the define already describes what this define is about. If you are not sure if you want it or not, just create the project once with and then without this flag set to Y(es) and compare the results. But once again: If you are new to the pPHPlib, you might want to turn this on.

Creating the project

After you have finished editing the config file according to your needs, you have to run parse.php. This is normally done by entering php parse.php on the command line. The latest distributions of PHP all install a CLI (command line interpreter) version of PHP, so this should be no problem on a standard installation. If it is not done in your case you have either to install a package with includes the CLI or change your compile settings to also create the CLI.

After entering above command, the parse process will begin and you will be left with a new subdirectory with the name of your project (in lowercase). Please also watch the parse process for errors, in case something went wrong.

Setting up the DB

In the subdirectory tab of your new project will be a file called init_prod.ddl. Please edit this file according to your needs and run it as the superuser (normally root) on the database (tip: use 'source'). There will be also files for test and dev, if you chose to create them. Please review the .ddl's very carefully and make sure not to create DB's, users and/or tables twice (no harm done if you do though, as the DB just will return an error).

Moving the directory to its final destination

pPHPskel is not (yet) moving the newly created project to its final destination (e.g. /var/www/newproj), but leaves it in the subdirectory. This final set has to be done by yourself (just use cp -R for recursive copy). The reason for this is that locations might be on different servers (esp with a production/uat/development setup) and that parse.php might not have write access. There might however be some work put into it in the future to provide more comfort here.

Things to watch out for are:

  • Make sure that the pPHPlib is located where you specified it in the config files. If this location is in the root of the new project, do not forget to copy the pPHPlib over there!
  • Are the pubic and secure directories readable by the webserver?
  • Are no other directories readable by the webserver? Remember that only public/ and secure/ must be readable! (TIP: use Alias or AliasMatch).
  • Does the log file directory exist (if configured) and is it writeable by the webserver?

Configuring your webserver

Make sure that your files are all accessible from the webserver. Like noted above, you might use Alias and AliasMatch for this. If you put the new project in your home directory you might need to create symlinks to the public and secure directories (depending on your setup).

Trying it out

If all went OK so far, you can now connect to the URL you gave in the config file and you should see the index page with some links. From here now you can now add your own pages.

The directory layout of the project