Skip to main content

2 posts tagged with "PHP"

View All Tags

· 5 min read

I have been playing around with PHP a lot with a Baidu open-source project -> http://task.redefime.com/app/list recently. The project used mainly CakePHP as the back-end, which is an elegant solution for MySQL+PHP stack. I am writing this blog for documentation and reference purposes for my future. I am getting more and more like the character in Nolan's movie 'Memento' as I need to keep writing things down to keep me not running around the circles and trapped by the same set of pitfalls.

Environment Set Up

  1. Get XAMPPP

  2. Set up Virtual Host : <virtualhost> tag is used when you have multiple projects and you want to host them on different domain names so it doesn't get messed up:

    1. Open Config File:
    2. set up directorys and VirutalHost mapping (DocumentRoot is your project root, ServerName is going to be the domain name you want to host the DocumentRoot Files in):
    <VirtualHost *:80>
    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/tree-outliner"
    ServerName test-outliner.com
    </VirtualHost>

    <VirtualHost *:80>
    DocumentRoot "/Users/Carl/Development/Learn/cakephpforum.com/app"
    ServerName cakephpforum.com
    </VirtualHost>

· 4 min read

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs. (Definition on its homepage http://www.slimframework.com/)

Here you can have a taste of it :)

<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require 'vendor/autoload.php';

$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello, $name");

return $response;
});
$app->run();

I just got introduced to Slim Framework recently, and speaking frankly it is not a good experience working with it and the poor community is nothing like npmjs, which is a place where I hang around most of the time. All the tutorials online are mostly theory-based and really not organized, some of them don't even run properly.