Fork me on GitHub

Application - Get Start

#Get Start

#Overview

As we mentioned that the CL framework has a few system requirements. if you installed all requirements on your machines. move down and get more information. If NOT, move to `Installation`


Firstly, at least you need 3 files .htaccess, cafelatte.json, index.php except the Composer's files(composer .json)

Secondly, you have to create folders for storing log messages, optionally create template's in/output folders, and need somewhere to upload files if you use it

.htaccess

in case of apache web server


Options +FollowSymLinks
RewriteEngine On

RewriteCond % !-d
RewriteCond % !-f
RewriteRule ^ index.php [L]

.cafelatte.json (this is a sample json.)


{
  "server_name": "GAME SERVER",
  "server_type": "develop",
  "project": {
    "name": "hello world project",
    "path": "/home/projects/my_projects/",
    "version": "0.1.1",
    "url": "http://my_projects.com",
    "security_level": "normal"
  },
  "log": {
    "level": "debug",
    "path": "/home/projects/my_projects/logs/"
  },
  "template": {
    "input": "YOUR_HTML_FILE_PATH",
    "output": "YOUR_PHP_FILE_PATH",
    "user": "root",
    "group": "root"
  },
  "upload": {
    "on_off": "on",
    "path": "/home/projects/my_projects/upload/"
  },
  "security": {
    "key": "dfsadflwqorkfdskjfsdljfsdafjl"
  },
  "database": {
    "on_off": "on",
    "db_host": [
      "YOUR_DATABASE_HOST"
    ],
    "db_name": "YOUR_DATABASE_NAME",
    "db_user": "YOUR_DATABASE_USER",
    "db_pass": "YOUR_DATABASE_PASSWORD"
  },
  "tmp": {
    "path": "/home/projects/my_projects/tmp/"
  }
}

* Few keys are mandatory including "level, path" in log / "path", "url" of project , For moving the next step, it has to create folders on your machines.

#Web Server Configuration

#URLs Mapping

Apache

The CL framework requires a public/.htaccess file that is used to provide URLs without the index.php front controller in the path. Before serving CL framework with Apache, be sure to enable the mod_rewrite module so the .htaccess file will be honored by the server. If the .htaccess file that ships with CL framework does not work with your Apache installation, try this alternative:


Options +FollowSymLinks
RewriteEngine On

RewriteCond % !-d
RewriteCond % !-f
RewriteRule ^ index.php [L]

.htaccess download

Nginx

If you are using Nginx, the following directive in your site configuration will direct all requests to the index.php front controller:


location / {
    try_files $uri $uri/ /index.php?$query_string;
}

.index.php


<?php

require_once("/home/projects/my_project/vendor/autoload.php");

class MyTestIndex extends \CafeLatte\Core\BaseRoute implements \CafeLatte\Interfaces\RouterInterface
{
    public function routing()
    {
        //Write your php code here(GET/POST/DELETE/PUT)
        echo "Hello World";
    }

}

$framework = new MyTestIndex("/home/projects/my_project/cafelatte.json");
$framework->execute();

*You should put a absolute(full) path of `cafelatte.json` and put a filename the end of the path.

ex) `/home/projects/my_project/cafelatte.json`

#Tutorial

To get more information, move to tutorial page, Click `Here`