HomePHP Page 5 - Building a Site Engine with PHP, Part 2
Bring it Together - PHP
If you read the first article in this series, you’d know that we’re about to start talking about the plug-in and module system for our site engine. Along with the plug-ins and modules, we’re also going to be discussing some of the general functions that are needed to make site engine work correctly.
We have everything here ready to go. Now we just need to put it all together so that it will run. I made a file that basically includes all the files we've just put together. That way we only have to include one file on our index page so it doesn't become all cluttered up. Save this as "your_site_dir/inc/core.inc.php".
<?PHP
@include('inc/config.inc.php'); $config = new config();
@include('inc/sql.inc.php'); $sql = new sql($config->dbhost,$config->dbuser,$config->dbpass); $sql->_select_db($config->dbname);
@include('inc/site.inc.php'); $site = new site();
@include('inc/plugins.inc.php'); $plugins = new plugins("1");
@include('inc/modules.inc.php'); $modules = new modules("1");
?>
Pretty simple and self explanatory. All we did was include all the files in the /inc directory, then we initialized the classes that are defined within them.
Now all we have left is the index page -- another simple bit of work. All we really have in the index page is a quite common parse time function and an include. Save this file as "your_site_dir/index.php".
That's all we have to do for the plug-in and module systems. In the next article in the series, we'll go through the authentication system and the block system. I'll also show you how the database and directories should be set up so you can set up your first plug-in and module and give it all a try. Following that will be an article illustrating how to build the template and loading system of the site engine. Then finally, there will be an article on making an administration page and how to quickly build a site with the site engine.