Database Reference
In-Depth Information
Slim PHP
Slim is a PHP implementation of what is often called a micro framework . The aim of a micro framework is to help you
quickly build out powerful web applications and APIs using only what is absolutely necessary to get the job done.
Slim is maintained by the outstanding PHP dev josh Lockhart and supported by a number of equally
outstanding committers, including our technical reviewer jeremy Kendall. If you would like to get involved with Slim,
please visit http://www.slimframework.com/ .
Note
Listing 8-3. SlimPHP Example of GET Route
<?php
... include file code omitted for brevity...
//setup app
$app = new \Slim\Slim(array(
'log.enabled' => true,
'log.level' => \Slim\Log::DEBUG,
'log.writer' => $logWriter,
'view' => new \Slim\Views\Twig()
));
...code omitted for brevity...
// new GET route to /somepath
$app->get('/somepath', function() use ($app){
//render this html file
$app->render('graphs/social/posts.html');
});
Local Apache Configuration
To follow the sample application found later in this chapter, you will need to properly configure your local Apache
webserver to use the workspace project in Eclipse as the document root. One way to accomplish this is adding a virtual
host to Apache. Listing 8-4 covers the basic configuration for adding a virtual host to the httpd-vhosts.conf file .
If you do not have Apache HTTP installed, go to http://httpd.apache.org/ and follow the instructions
based on your operating system. Configuring PHP with a local instance of Apache HTTP is out of scope for this topic, but
you can find the basic configuration steps at http://www.php.net/manual/en/refs.utilspec.server.php .
Important
Listing 8-4. Minimum Configuration for httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
# add practicalneo4j-php to your hosts file OR substiute your
ServerName practicalneo4j-php
DocumentRoot /path/to/your/workspace/practicalneo4j-php/app/public
 
 
Search WWH ::




Custom Search