{"id":15277393,"url":"https://github.com/codera21/simpleframework","last_synced_at":"2026-02-15T19:04:04.640Z","repository":{"id":56955599,"uuid":"147081212","full_name":"codera21/SimpleFramework","owner":"codera21","description":"It is a MVC framwork made in PHP, inspired by CodeIgniter","archived":false,"fork":false,"pushed_at":"2020-10-01T13:03:35.000Z","size":578,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-04T15:52:54.852Z","etag":null,"topics":["php","php-framework","php-library","php7"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codera21.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-02T12:02:14.000Z","updated_at":"2025-08-25T00:23:16.000Z","dependencies_parsed_at":"2022-08-21T08:50:36.159Z","dependency_job_id":null,"html_url":"https://github.com/codera21/SimpleFramework","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/codera21/SimpleFramework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codera21%2FSimpleFramework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codera21%2FSimpleFramework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codera21%2FSimpleFramework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codera21%2FSimpleFramework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codera21","download_url":"https://codeload.github.com/codera21/SimpleFramework/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codera21%2FSimpleFramework/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29487397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T15:33:17.885Z","status":"ssl_error","status_checked_at":"2026-02-15T15:32:53.698Z","response_time":118,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["php","php-framework","php-library","php7"],"created_at":"2024-09-30T11:05:28.957Z","updated_at":"2026-02-15T19:04:04.624Z","avatar_url":"https://github.com/codera21.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimpleFramework\nIt is a MVC framwork made in PHP.\n\n## Requirement \nSince I am using latest version of twig and it needs at least php 7.0. \nyou will need what a typical php project will require. \n   \n## Installation\nrun: \n- `composer create-project codera21/sf project_name`\n- `cd project_name`\n- `run php -S localhost:8080`\n\n## Guidelines\n1. Controller Name must be in `CapitalCase` and must follow `Controller` suffix\n2. Function inside the Controller also must be in `CapitalCase` and must follow `Action` suffix\n3. Table in Database and it's respective Model Class name must be in pural.\n\n## Getting Started\n\n### Using the Controller\n Inside `Application\\WebInterface`you will see three folders `Controllers` , `Models` , `ViewModels` , `Views`. Goto Controllers then Create one new Controller Let's Say `PageController.php`  with one method `IndexAction()` the code is as shown below:\n```\n\u003c?php \nnamespace WebInterface\\Controllers;\nuse System\\MVC\\Controller;\n\nclass PageController extends Controller\n{\n    public function IndexAction()\n    {\n        echo(\"Hello World\");\n    }\n}\n```\nThen in the output navigate to `\u003cHost\u003e/\u003cProjectName\u003e/Page/Index` or `\u003cHost\u003e/\u003cProjectName\u003e/Page` in my case `http://localhost:90/SimpleFrameWork/Page` then you will see the page with string \"Hello World\" echoed out. \nYes the routes are created automatically in this format : `\u003chost\u003e/\u003ccontroller\u003e/\u003caction/method\u003e`\n\n##### Parameters\nIn the same PageController I created a new method AddAction(int $num1 , int $num2) the code is as follows: \n```\n    public function AddAction($num1, $num2)\n    {\n        echo $num1 + $num2;\n    }\n```\nNow if you navigate to link like `http://localhost:90/SimpleFrameWork/Page/Add/5/5` then you will see in the page 10 echoed out.\n\n### Dealing with database\nOne of the strong suite of the SimpleFramework is its easy to use out of the box ORM for common database queries:\n\n#### Connection to database \nGoto `Application/Config/DbConfig.php` and fill up the ServerName, Username, Password and DatabaseName. \neg: \n```\n   function __construct()\n    {\n        $this-\u003edatabaseConnection = new DatabaseConnection();\n\n        $this-\u003edatabaseConnection-\u003eServerName = 'localhost';\n        $this-\u003edatabaseConnection-\u003eUsername = 'root';\n        $this-\u003edatabaseConnection-\u003ePassword = '';\n        $this-\u003edatabaseConnection-\u003eDatabaseName = 'products';\n    }\n```\n### Model \nSuppose you have a table named items with columns ID , ItemName, ItemPrice, ItemCategory. Then in `WebInterface/Models` create a class `Items` like: \n```\n\u003c?php\nnamespace WebInterface\\Models;\n\nuse System\\MVC\\ModelAbstract;\n\nclass Items extends ModelAbstract\n{\n    public $ID;\n    public $ItemName;\n    public $ItemPrice;\n    public $ItemCategory;\n}\n```\n### Repository \nMake a Repo of database functions in `Application/Repository` make a new class ItemRepo with constructor initialized with Model class ( made above) and table like this:\n```\n\u003c?php\nuse System\\Repositories\\Repo;\n\nclass ItemRepo extends Repo\n{\n    private $table = 'items';\n    private $modelClass = 'WebInterface\\\\Models\\\\Items';\n\n    public function __construct()\n    {\n        parent::__construct($this-\u003etable, $this-\u003emodelClass);\n    }\n}\n```\n### Calling Common database queries:\nIn the PageController's `IndexAction` I can create an object of `ItemRepo` and use its common queries:\n```\n public function IndexAction()\n    {\n        $itemRepo = new ItemRepo();\n        $itemData = $itemRepo-\u003eGetAll();\n        $this-\u003eload-\u003eTwigView('Page/index', ['data' =\u003e $itemData]);\n    }\n```\nIt is a good idea to make object in the constructor if more than one function uses the particular Repository: \n```\n\u003c?php\nnamespace WebInterface\\Controllers;\n\nuse Repositories\\ItemRepo;\nuse System\\MVC\\Controller;\n\nclass PageController extends Controller\n{\n    private $itemRepo;\n    public function __construct()\n    {\n        parent::__construct();\n        $this-\u003eitemRepo = new ItemRepo();\n    }\n    public function IndexAction()\n    {\n        $itemData = $this-\u003eitemRepo-\u003eGetAll();\n        $this-\u003eload-\u003eTwigView('Page/index', ['data' =\u003e $itemData]);\n    }\n}\n```\n\n#### list of common queries \n```\n Insert($model, $removeFields = array(), $table = null) // this is protected function\n UpdateTable($model, $removeFields, $id = null, $table = null, $updateFrom = null, $updateFromValue = null) // this is also protected\n GetCurrentDate()\n GetCurrentDateTime()\n Delete($id, $idFieldName = null)\n GetById($id, $idFieldName = null)\n GetAllByViewModelWithOutJoin($viewModelClass, $whereConditions = array())\n GetAll()\n Check($id)\n```\n#### custom query ( we use PDO)\nyou can create your own custom functions and make your own queries like this in `Repository/ItemRepo` new function `Custom` is made:\n```\npublic function Custom($id)\n    {\n        $sql = \"select * from items where ID = :ID\";\n        $sqlQuery = $this-\u003edbConnection-\u003eprepare($sql);\n        $sqlQuery-\u003ebindParam(':ID', $id);\n        $sqlQuery-\u003eexecute();\n    }\n```\n\n#### Many More Features\nThere are many more features of SimpleFramework, that is not covered here. please go through this framework and see for yourself :) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodera21%2Fsimpleframework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodera21%2Fsimpleframework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodera21%2Fsimpleframework/lists"}