Saturday, February 18, 2012

Why dont you create your own CMS???--Part 2

Working with configuratin files

So here we are going to work with 'main' folder where we will define our server settings and functions in a 'functions.php'.
  • Create a database named 'stupid'.
  • Open 'main' folder.
  • Create a new folder and name it as 'config'.
  • Create a file named 'base.php' inside config directory.
  • Open the file in an editor.
<?php
define('DB_HOST','localhost');
define('DB_USER','YOUR USER NAME');
define('DB_PASS','YOUR PASSWORD');
define('DB_NAME','stupid');
define('SITENAME','My first CMS');
define('BASE','http://localhost/stupid');
define('CLASSPATH','include');
define('THEMESPATH','themes');
define('MODULESPATH','modules');
?>

We defined constant DB_HOST and assigned a value 'localhost'.
BASE==>'YOUR WEB URL'
Other constant definition are self explanatory.
what are constants in php?
       
"A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script . A constant is case-sensitive by default. By convention, constant identifiers are always uppercase."
eg:-    define('PI',3.14);
so you have finished the cofiguratin of your stupid cms.Next post we will be discussing about the classes required to create your own CMS.While I prepare the next post,you better refresh your knowledge about php classes.

2 comments:

  1. Great and impressive article!! Got to learn and know more about web development. To know more refer create website for much more unique ideas.PHP Training in Chennai | Best PHP training in Chennai

    ReplyDelete