{"id":17216306,"url":"https://github.com/nerandell/cymbaline","last_synced_at":"2025-03-25T13:42:59.718Z","repository":{"id":56960789,"uuid":"47389135","full_name":"nerandell/cymbaline","owner":"nerandell","description":"Yet Another PHP web service framework","archived":false,"fork":false,"pushed_at":"2015-12-07T13:28:27.000Z","size":35,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T12:32:31.682Z","etag":null,"topics":["framework","php","webframework"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nerandell.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-04T07:42:15.000Z","updated_at":"2015-12-24T13:58:31.000Z","dependencies_parsed_at":"2022-08-21T09:20:57.773Z","dependency_job_id":null,"html_url":"https://github.com/nerandell/cymbaline","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerandell%2Fcymbaline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerandell%2Fcymbaline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerandell%2Fcymbaline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerandell%2Fcymbaline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nerandell","download_url":"https://codeload.github.com/nerandell/cymbaline/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245473638,"owners_count":20621266,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["framework","php","webframework"],"created_at":"2024-10-15T03:27:26.391Z","updated_at":"2025-03-25T13:42:59.688Z","avatar_url":"https://github.com/nerandell.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"cymbaline\n=========\n.. image:: https://api.travis-ci.org/nerandell/cymbaline.svg?branch=master\n    :target: https://travis-ci.org/nerandell/cymbaline\n|    \n`cymbaline` is yet another PHP web service framework. It follows MVC pattern \nand makes development of web applications easy by including commonly used tasks\nin the framework itself to reduce effort and time taken for development.\n\nGetting Started\n---------------\n- PHP 5.3.x is required\n- Install Composer_\n- Setup URL rewriting so that all requests are handled by index.php\n.. _composer: https://getcomposer.org/\n\nInstallation\n------------\n- Get Composer\n- Require cymbaline with  ``php composer.phar require cymbaline/cymbaline``\n- Add the following to your application's main PHP file: ``require 'vendor/autoload.php';``\n\nYou can also add the following to an existing ``composer.json`` file :  ``\"cymbaline/cymbaline\": \"*\"``. \nA sample ``composer.json`` would look like this:\n\n.. code-block:: json\n\n    {\n        \"name\": \"cymbaline/cymbaline_demo\",\n        \"description\": \"Demo for using cymbaline\",\n        \"authors\": [\n            {\n                \"name\": \"Ankit Chandawala\",\n                \"email\": \"ankitchandawala@gmail.com\"\n            }\n        ],\n        \"require\": {\n            \"cymbaline/cymbaline\": \"@dev\"\n        },\n        \"minimum-stability\": \"dev\"\n    }\n\n``cymbaline`` requires several libraries to work.\n\n- Klein_ is used for routing.\n- It uses Eloquent_ to work with your databases.\n- Twig_ is used as a templating engine for rendering views.\n.. _Klein: https://github.com/chriso/klein.php\n\n.. _Eloquent: http://laravel.com/docs/5.0/eloquent\n.. _Twig: http://twig.sensiolabs.org/\n\nUsage\n-----\nTo see a sample app, you can check a simple demo here_.\n\n.. _here: https://github.com/nerandell/cymbaline_demo\n\nOnce ``cymbaline`` is installed, start routing all your requests to ``index.php``.\nHere is a sample nginx configuration to route the requests\n\n.. code::\n\n    location / {\n                try_files $uri $uri/ /index.php;\n                root   /path_to_your_root_dir;\n                index  index.html index.htm index.php;\n            }\n\nAdd the following lines to our ``index.php`` file : ``require 'vendor/autoload.php';``\n\n``cymbaline`` is based on MVC_ design pattern. You can start defining your models, \ncontrollers and views and ``cymbaline`` will stitch it all for you using short and concise code\nto reduce the development times needed while building a web application.\n\nYou app code should reside in top-level directory named ``app``. Then you can start adding\nyour models, contollers and views. Typically your directory structure would look like this:\n\n.. code::\n\n    app\n    ├── config\n    │   └── database.php\n    ├── controllers\n    │   ├── CompanyController.php\n    │   └── UserController.php\n    ├── models\n    │   ├── Company.php\n    │   └── User.php\n    ├── routes.php\n    └── views\n        └── index.html\n\n.. _MVC : https://msdn.microsoft.com/en-us/library/ff649643.aspx\n\nThe models that you define reside in the ``app/models`` directory. \nTo create a model, you have to extend from ``BaseModel`` class which is provided \nby ``cymbaline``\n\n.. code-block:: python\n\n    use Cymbaline\\BaseModel;\n    \n    class User extends BaseModel\n    {\n    \n    }\n    \n``BaseModel`` internally uses ``Model`` class from ``Eloquent`` and\nsame options are available for configuration. Check out Eloquent documentation_\nfor more information. \n\n.. _documentation: http://laravel.com/docs/5.1/eloquent\n\n``cymbaline`` picks up your database configuration from ``config/database.php``.\nYour database file will look like this:\n\n.. code-block:: php\n\n        \u003c?php\n        \n        $connection = [\n            'host' =\u003e 'your-host',\n            'driver'    =\u003e 'mysql',\n            'database'  =\u003e 'your-database',\n            'username'  =\u003e 'your-user',\n            'password'  =\u003e 'your-password',\n            'charset'   =\u003e 'utf8',\n            'collation' =\u003e 'utf8_unicode_ci',\n            'prefix'    =\u003e ''\n        ];\n\n\n\nNow define a controller named ``UserController`` directory like this:\n\n.. code-block:: python\n\n    use Cymbaline\\Controller;\n    \n    class UserController extends Controller\n    {\n    \n    }\n\nYou can also define a view in ``app/views/`` directory which will be rendered using ``Twig``.\n\nOnce, you add a model and an associated controller, ``cymbaline`` can automatically create\nRESTful crud api for you. \n\nFor example, to create a new user:\n\n.. code-block :: bash\n\n    $ curl -X POST -H \"Content-Type: application/json\" -d '{\"name\": \"User1\"}' 'http://localhost:8080/user'\n    \nTo retrive a user:\n\n.. code-block :: bash\n\n    $ curl -X GET -H 'http://localhost:8080/user/1'\n  \nwill give the output:\n\n.. code-block:: json\n\n    {\n    \t\"id\": 1,\n    \t\"name\": \"User1\",\n    \t\"created_at\": \"2015-12-06 03:47:59\",\n    \t\"updated_at\": \"2015-12-06 03:47:59\"\n    }\n\nHowever, it is entirely upto you to define which apis you want and \nyou can override the default behaviour.\n\nYou can define your own routes too. Custom routes are defined in ``app/routes.php`` directory.\nHere is a sample route added. ``cymbaline`` uses Klein for routing and the routing options.\n\n\n.. code-block:: php\n\n    use Cymbaline\\Route;\n    \n    Route::addRoute('get', '/hello/[:id]', function($request) {\n        $controller = new UserController();\n        $controller-\u003etest_custom_route($request-\u003eid);\n    });\n\nThen add a method to the controller:\n\n.. code-block:: php\n\n    use Cymbaline\\Controller;\n    \n    class UserController extends Controller\n    {\n        public function test_custom_route($id)\n        {\n            $user = call_user_func(array($this-\u003e_model, 'find'), $id);\n            $this-\u003erenderView('index.html', array('name'=\u003e$user-\u003ename));\n        }\n    }\n\n``renderView`` method uses Twig_ to render view.\n\n.. _Twig: http://twig.sensiolabs.org/\n\nYour index.html will look like this:\n\n.. code-block :: html\n\n    \u003chtml lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\"\u003e\n    \u003chead\u003e\n        \u003cmeta name=\"generator\" content=\n        \"HTML Tidy for Linux/x86 (vers 25 March 2009), see www.w3.org\" /\u003e\n        \u003cmeta charset=\"UTF-8\" /\u003e\n    \n        \u003ctitle\u003eTitle\u003c/title\u003e\n    \u003c/head\u003e\n    \n    \u003cbody\u003e\n        Hello {{name}}\n    \u003c/body\u003e\n    \u003c/html\u003e\n  \nLicense\n-------\n``cymbaline`` is offered under the MIT license.\n\nSource code\n-----------\nThe latest developer version is available in a github repository:\nhttps://github.com/nerandell/cymbaline\n\nWhat does Cymbaline mean?\n-------------------------\nCymbaline is a Pink Floyd song from the album, Soundtrack from the Film More.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerandell%2Fcymbaline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnerandell%2Fcymbaline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerandell%2Fcymbaline/lists"}