Getting Started
From PHPDevShell
This part assumes that you have already installed PHPDevShell and have it up and running. You would also need to download a copy of PHPDevShell for examples sake.
Contents |
Intro
Where would I typically use PHPDevShell? PHPDevShell would typically be used to develop general web based applications. It is not a CMS (Content Management System) or an MVC Framework nor does it pretend to be one of those solutions. PHPDevShell is essentially a ready made GUI application where you can immediately start with the development work that matters most, your application. For security and usability it already provides you with user registration and management, role management, group management, access rights security, important system settings, templates, control panels, cronjob management, menu management, plugin management etc.
Why would I want to use PHPDevShell? PHPDevShell provides the ability for you to get a PHP back-end system up and running in an incredibly short amount of time while not taking short cuts on things such as security and resource usage. It’s made as light as possible as to not interfere with your application yet allows you to heavily customise the look and feel if you have the time. Why re-invent the wheel when you can gain months of work instantly by using PHPDevShell?
The Beginning
By now you should have installed PHPDevShell (see Installing PHPDevShell) already.
For this tutorial we will use the Skeleton Plugin so you can get into the tutorial as quickly as possible skipping all the boring stuff figuring out how a plugin structure should look. You can see how to install it here : Installing plugins for PHPDevShell
Please download demo plugins including the Skeleton plugin here, Plugins
You can also download and install the PHPDevShell plugin with all the demo tutorial plugins included here : Plugins
PHPDevShell is a unique framework in the sense that you can start working on your project immediately! Yes its true, PHPDevShell has a very very easy learning curve. This was the whole idea of its creation, you don’t need to learn a “new” language to be able to start using it.
The basic principle.
So creating your first script as easy as pie, remember we are going to use the skeleton plugin for this.
- Browse and create example.php in 'plugins/Skeleton/example.php'.
- Also create a example.tpl (Smarty) inside 'plugins/Skeleton/templates/example.tpl' (Note that by default the template uses the same filename as its php counterpart relative to it inside the templates folder).
- Now edit your example.php file and write this;
// You will always need to add this security string to all your files. (is_object($security)) ? $this->security->load_security() : exit('Access Denied!'); // Lets start coding, first lets add some nice Typography. $this->template->heading('This is my first script for PHPDevShell'); $this->template->info('This script does not do much but I am still learning.'); // Ok now we can fall back to standard php coding really, lets set a few variables and pass it to Smarty Template system. $my_name = "Peter Exampler"; // And lets add a random age. $my_age = rand(1, 80); // Ok lets pass it on to our template; $this->template->set('my_name', $my_name); $this->template->set('my_age', $my_age); // We can now ask for the template; $this->template->show();
Good, now edit the example.tpl file;
<!-- Our general template cloud already adds the main surrounding table --> <tr> <td> Name </td> <td> {$my_name} </td> </tr> <tr> <td> Age </td> <td> {$my_age} </td> </tr>
Ok, now that you have script and a template, lets get your script running inside PHPDevShell;
- Browse to System Management -> Menu Admin -> New Menu.
- Complete the settings like in the picture (Fig 1) and hit save.
Good, it should tell you that the file was safely saved and the path should be marked as found. Well that should be it, you can now access your newly created script from the menu system in the root. Can you see how easy it is, its still php as you know it, we can now start expanding your script.
The framework.
PHPDevShell besides having an already working gui provides the developer to some very useful classes and methods. You can still add your favorite class or library to use inside PHPDevShell. PHPDevShell has the basic build in supporting methods and concentrates not to bloat the software.
To add your own class, simply add your class in the 'includes' folder of your plugin, as an example 'plugins/Skeleton/includes/example.class.php', you can then call your class by just doing:
$myclass = new example(); // Note that your example.class.php must contain class example {
Lets have a look at the fundamental 6 object you will be using in PHPDevShell to get tasks done quickly and easily! These objects are always available to you and does not need to be called separately.
// Holds everything about the system session, from user data to server data. $configuration-> or $this->configuration // The db class contains basic database methods and information to manage your scripts. $db-> or $this->db // Contains navigation values and navigation methods. $navigation-> or $this->navigation // Contains navigation values and navigation methods. $security-> or $this->security Contains all necessary security methods. // Contains methods to handle core processing. $core-> or $this->core // All template methods and typographic. $template-> or $this->template
Remember to view the API documentation to see exactly what methods and classes are available to you.
Ok lets see how we could utilize some classes and do something useful by continuing to build in your example.php file;
// You will always need to add this security string to all your files. (is_object($security)) ? $this->security->load_security() : exit('Access Denied!'); // Lets start coding, first lets add some nice Typography. $this->template->heading('This is my first script for PHPDevShell'); $this->template->info('This script does not do much but I am still learning.'); // Ok now we can fall back to standard php coding really, lets set a few variables and pass it to Smarty Template system. $my_name = $this->configuration['user_display_name']; // And lets add a random age. $my_age = $this->configuration['user_id']; // Cool, lets log something to the watchdog logger while displaying it too. if ($this->configuration['user_role'] != $this->configuration['root_role']) { $this->template->warning(__('Hey you are not a root master user, I know it cause I am smart.')); } else { $this->template->ok(__('Ooo, master you are a root admin!.')); } // Ok lets pass it on to our template; $this->template->set('my_name', $my_name); $this->template->set('my_age', $my_age); // We can now ask for the template; $this->template->show();
Conclusion
And so you have hundreds of useful methods available to help you rapidly develop your application.
Please view the example plugins to see an example of how you can quickly create an application. You can also open all other PHPDevShell plugin source files to see how things are done, they are used exactly in the same way as your plugins will work. The plugins can be located in the PHPDevShell downloaded package under plugins.

