<commit_before>cymbaline
=========

`cymbaline` is yet another PHP web service framework. It follows MVC pattern 
and makes development of web applications easy by including commonly used tasks
in the framework itself to reduce effort and time taken for development.

Getting Started
---------------
- PHP 5.3.x is required
- Install Composer_
- Setup URL rewriting so that all requests are handled by index.php
.. _composer: https://getcomposer.org/

Installation
------------
- Get Composer
- Require cymbaline with  ``php composer.phar require cymbaline/cymbaline``
- Add the following to your application's main PHP file: ``require 'vendor/autoload.php';``

You can also add the following to an existing ``composer.json`` file :  ``"cymbaline/cymbaline": "*"``. 
A sample ``composer.json`` would look like this:

.. code-block:: json

    {
        "name": "cymbaline/cymbaline_demo",
        "description": "Demo for using cymbaline",
        "authors": [
            {
                "name": "<NAME>",
                "email": "<EMAIL>"
            }
        ],
        "require": {
            "cymbaline/cymbaline": "@dev"
        },
        "minimum-stability": "dev"
    }

``cymbaline`` requires several libraries to work.

- Klein_ is used for routing.
- It uses Eloquent_ to work with your databases.
- Twig_ is used as a templating engine for rendering views.
.. _Klein: https://github.com/chriso/klein.php

.. _Eloquent: http://laravel.com/docs/5.0/eloquent
.. _Twig: http://twig.sensiolabs.org/

Usage
-----
To see a sample app, you can check a simple demo here_.

.. _here: https://github.com/nerandell/cymbaline_demo

Once ``cymbaline`` is installed, start routing all your requests to ``index.php``.
Here is a sample nginx configuration to route the requests

.. code::

    location / {
                try_files $uri $uri/ /index.php;
                root   /path_to_your_root_dir;
                index  index.html index.htm index.php;
            }

Add the following lines to our ``index.php`` file : ``require 'vendor/autoload.php';``

``cymbaline`` is based on MVC_ design pattern. You can start defining your models, 
controllers and views and ``cymbaline`` will stitch it all for you using short and concise code
to reduce the development times needed while building a web application.

You app code should reside in top-level directory named ``app``. Then you can start adding
your models, contollers and views. Typically your directory structure would look like this:

.. code::

    app
    ├── config
    │   └── database.php
    ├── controllers
    │   ├── CompanyController.php
    │   └── UserController.php
    ├── models
    │   ├── Company.php
    │   └── User.php
    ├── routes.php
    └── views
        └── index.html

.. _MVC : https://msdn.microsoft.com/en-us/library/ff649643.aspx

The models that you define reside in the ``app/models`` directory. 
To create a model, you have to extend from ``BaseModel`` class which is provided 
by ``cymbaline``

.. code-block:: python

    <?php
    
    class User extends BaseModel
    {
    
    }
    
``BaseModel`` internally uses ``Model`` class from ``Eloquent`` and
same options are available for configuration. Check out Eloquent documentation_
for more information. 

.. _documentation: http://laravel.com/docs/5.1/eloquent

``cymbaline`` picks up your database configuration from ``config/database.php``.
Your database file will look like this:

.. code-block:: php

        <?php
        
        $connection = [
            'host' => 'your-host',
            'driver'    => 'mysql',
            'database'  => 'your-database',
            'username'  => 'your-user',
            'password'  => '<PASSWORD>',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => ''
        ];



Now define a controller named ``UserController`` directory like this:

.. code-block:: python

    <?php
    
    class UserController extends Controller
    {
    
    }

You can also define a view in ``app/views/`` directory which will be rendered using ``Twig``.

Once, you add a model and an associated controller, ``cymbaline`` can automatically create
RESTful crud api for you. 

For example, to create a new user:

.. code-block :: bash

    $ curl -X POST -H "Content-Type: application/json" -d '{"name": "User1"}' 'http://localhost:8080/user'
    
To retrive a user:

.. code-block :: bash

    $ curl -X GET -H "Content-Type: application/json"  'http://localhost:8080/user/1'
  
will give the output:

.. code-block:: json

    {
    	"id": 1,
    	"name": "Ankit",
    	"created_at": "2015-12-06 03:47:59",
    	"updated_at": "2015-12-06 03:47:59"
    }

However, it is entirely upto you to define which apis you want and 
you can override the default behaviour.

You can define your own routes too. Custom routes are defined in ``app/routes.php`` directory
Here is a sample route added. ``cymbaline`` uses Klein for routing and the routing options.


.. code-block:: php

    Route::addRoute('get', '/hello/[:id]', function($request) {
        $controller = new UserController();
        $controller->test_custom_route($request->id);
    });

Then add a method to the controller:

.. code-block:: php

    <?php
    
    class UserController extends Controller
    {
        public function test_custom_route($id)
        {<commit_msg>Fix typos<commit_after>cymbaline
=========

`cymbaline` is yet another PHP web service framework. It follows MVC pattern 
and makes development of web applications easy by including commonly used tasks
in the framework itself to reduce effort and time taken for development.

Getting Started
---------------
- PHP 5.3.x is required
- Install Composer_
- Setup URL rewriting so that all requests are handled by index.php
.. _composer: https://getcomposer.org/

Installation
------------
- Get Composer
- Require cymbaline with  ``php composer.phar require cymbaline/cymbaline``
- Add the following to your application's main PHP file: ``require 'vendor/autoload.php';``

You can also add the following to an existing ``composer.json`` file :  ``"cymbaline/cymbaline": "*"``. 
A sample ``composer.json`` would look like this:

.. code-block:: json

    {
        "name": "cymbaline/cymbaline_demo",
        "description": "Demo for using cymbaline",
        "authors": [
            {
                "name": "<NAME>",
                "email": "<EMAIL>"
            }
        ],
        "require": {
            "cymbaline/cymbaline": "@dev"
        },
        "minimum-stability": "dev"
    }

``cymbaline`` requires several libraries to work.

- Klein_ is used for routing.
- It uses Eloquent_ to work with your databases.
- Twig_ is used as a templating engine for rendering views.
.. _Klein: https://github.com/chriso/klein.php

.. _Eloquent: http://laravel.com/docs/5.0/eloquent
.. _Twig: http://twig.sensiolabs.org/

Usage
-----
To see a sample app, you can check a simple demo here_.

.. _here: https://github.com/nerandell/cymbaline_demo

Once ``cymbaline`` is installed, start routing all your requests to ``index.php``.
Here is a sample nginx configuration to route the requests

.. code::

    location / {
                try_files $uri $uri/ /index.php;
                root   /path_to_your_root_dir;
                index  index.html index.htm index.php;
            }

Add the following lines to our ``index.php`` file : ``require 'vendor/autoload.php';``

``cymbaline`` is based on MVC_ design pattern. You can start defining your models, 
controllers and views and ``cymbaline`` will stitch it all for you using short and concise code
to reduce the development times needed while building a web application.

You app code should reside in top-level directory named ``app``. Then you can start adding
your models, contollers and views. Typically your directory structure would look like this:

.. code::

    app
    ├── config
    │   └── database.php
    ├── controllers
    │   ├── CompanyController.php
    │   └── UserController.php
    ├── models
    │   ├── Company.php
    │   └── User.php
    ├── routes.php
    └── views
        └── index.html

.. _MVC : https://msdn.microsoft.com/en-us/library/ff649643.aspx

The models that you define reside in the ``app/models`` directory. 
To create a model, you have to extend from ``BaseModel`` class which is provided 
by ``cymbaline``

.. code-block:: python

    <?php
    
    class User extends BaseModel
    {
    
    }
    
``BaseModel`` internally uses ``Model`` class from ``Eloquent`` and
same options are available for configuration. Check out Eloquent documentation_
for more information. 

.. _documentation: http://laravel.com/docs/5.1/eloquent

``cymbaline`` picks up your database configuration from ``config/database.php``.
Your database file will look like this:

.. code-block:: php

        <?php
        
        $connection = [
            'host' => 'your-host',
            'driver'    => 'mysql',
            'database'  => 'your-database',
            'username'  => 'your-user',
            'password'  => '<PASSWORD>',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => ''
        ];



Now define a controller named ``UserController`` directory like this:

.. code-block:: python

    <?php
    
    class UserController extends Controller
    {
    
    }

You can also define a view in ``app/views/`` directory which will be rendered using ``Twig``.

Once, you add a model and an associated controller, ``cymbaline`` can automatically create
RESTful crud api for you. 

For example, to create a new user:

.. code-block :: bash

    $ curl -X POST -H "Content-Type: application/json" -d '{"name": "User1"}' 'http://localhost:8080/user'
    
To retrive a user:

.. code-block :: bash

    $ curl -X GET -H "Content-Type: application/json"  'http://localhost:8080/user/1'
  
will give the output:

.. code-block:: json

    {
    	"id": 1,
    	"name": "User1",
    	"created_at": "2015-12-06 03:47:59",
    	"updated_at": "2015-12-06 03:47:59"
    }

However, it is entirely upto you to define which apis you want and 
you can override the default behaviour.

You can define your own routes too. Custom routes are defined in ``app/routes.php`` directory.
Here is a sample route added. ``cymbaline`` uses Klein for routing and the routing options.


.. code-block:: php

    Route::addRoute('get', '/hello/[:id]', function($request) {
        $controller = new UserController();
        $controller->test_custom_route($request->id);
    });

Then add a method to the controller:

.. code-block:: php

    <?php
    
    class UserController extends Controller
    {
        public function test_custom_route($id)
        {
{'fraction_non_alphanumeric': 0.1249418550562843, 'fraction_numerical': 0.009954414364126895, 'mean_word_length': 2.6280796490043876, 'pattern_counts': {'":': 28, '<': 17, '<?xml version=': 0, '>': 29, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6733471', 'n_tokens_mistral': 3368, 'n_tokens_neox': 3165, 'n_words': 1141}