{"id":17492000,"url":"https://github.com/alejandrosuero/todo-app-php","last_synced_at":"2026-05-11T02:20:51.430Z","repository":{"id":53061278,"uuid":"519345060","full_name":"AlejandroSuero/todo-app-php","owner":"AlejandroSuero","description":"A To Do web app made with PHP (with Smarty) and MySQL. Apache as server provider.","archived":false,"fork":false,"pushed_at":"2023-01-06T12:07:31.000Z","size":517,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T16:55:10.016Z","etag":null,"topics":["apache2","css","mysql","php8","smarty-template-engine","todo-app","todo-app-php","todoapp"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlejandroSuero.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-29T20:44:15.000Z","updated_at":"2022-07-29T22:24:51.000Z","dependencies_parsed_at":"2023-02-06T01:16:26.708Z","dependency_job_id":null,"html_url":"https://github.com/AlejandroSuero/todo-app-php","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/AlejandroSuero%2Ftodo-app-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlejandroSuero%2Ftodo-app-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlejandroSuero%2Ftodo-app-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlejandroSuero%2Ftodo-app-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlejandroSuero","download_url":"https://codeload.github.com/AlejandroSuero/todo-app-php/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246068302,"owners_count":20718503,"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":["apache2","css","mysql","php8","smarty-template-engine","todo-app","todo-app-php","todoapp"],"created_at":"2024-10-19T08:06:49.949Z","updated_at":"2026-05-11T02:20:51.381Z","avatar_url":"https://github.com/AlejandroSuero.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u003ccenter\u003e\u003cfont color=\"lightblue\"\u003eToDo Application\u003c/font\u003e\u003c/center\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg alt=\"ToDo App Logo\" src=\"public/images/icons/ToDo_App_icon_144x144.png\" width=\"144\" height=\"144\"/\u003e\n\u003c/p\u003e\n\nA web application made with **[PHP](https://www.php.net/)** and **[Smarty](https://www.smarty.net/)** as template engine, **[MySQL](https://www.mysql.com/)** for the database and **[Apache](https://www.apache.org/)** as the server.\n\n![Presentation Image](screenshots/presentation.png)\n\nIndex:\n\n1. [Backend](#backend)\n\n    - [Structure](#structure)\n\n    - [Handler](#handler)\n\n    - [Routing](#routing)\n\n2. [Frontend](#frontend)\n\n    - [Templates](#templates)\n\n    - [Styles](#styles)\n\nThe application classes for the MVC pattern are:\n\n```tree\n\n├─📂 classes\n    - 🐘 ToDoModel.class.php\n    - 🐘 ToDoView.class.php\n    - 🐘 ToDoController.class.php\n\n```\n\nThere are also some classes for the error handling and the configuration:\n\nSee more at [**classes**](public/classes/).\n\n## Backend\n\nI used **[MySQL](https://www.mysql.com/)**.\n\n### Structure\n\n| **Field**        | **Type**     | **Null**    | **Key**   | **Default**   | **Extra**      |\n|------------------|--------------|-------------|-----------|---------------|----------------|\n| task_id          | int(11)      | NO          | PRIMARY   | NULL          | auto_increment |\n| task_title       | varchar(30)  | NO          |           | NULL          |                |\n| task_description | varchar(200) | YES         |           | NULL          |                |\n| task_done        | tinyint(4)   | NO          |           | 0             |                |\n\n### Handler\n\nThe handler is a class that handles the database connection and the queries.\n\nUsing the **[PDO](https://www.php.net/manual/en/class.pdo.php)** class, the handler is able to execute queries and fetch the results.\n\n```php\n\npublic static function get_connection(): PDO {\n    $dbh = new Dbh();\n    $dsn = \"mysql:host=\" . $dbh-\u003eDB_HOST . \";dbname=\" . $dbh-\u003eDB_NAME;\n    $options = array(\n        PDO::ATTR_ERRMODE =\u003e PDO::ERRMODE_EXCEPTION,\n        PDO::ATTR_DEFAULT_FETCH_MODE =\u003e PDO::FETCH_ASSOC,\n        PDO::ATTR_EMULATE_PREPARES =\u003e false,\n    );\n    try {\n        $db = new PDO($dsn, $dbh-\u003eDB_USER, $dbh-\u003eDB_PASS, $options);\n    } catch (\\PDOException $e) {\n        $error = new ToDoError($e-\u003egetMessage(), (int) $e-\u003egetCode(), $e);\n        $error-\u003eshow_error();\n        throw new \\ToDoError($e-\u003egetMessage(), (int) $e-\u003egetCode());\n    }\n    return $db;\n}\n\n```\n\nSee more in the **[Dbh class](public/classes/Dbh.class.php)** file.\n\n### Routing\n\nI used **[.htaccess](public/.htaccess)** to redirect the requests to the **[route.php](public/route.php)** file.\n\n```apache\n\n\u003cIfModule mod_rewrite.c\u003e\n    \n    # Rewrite rules for the application\n    # Turns on the RewriteEngine\n    RewriteEngine On\n    # If the request is for a file, ignores it\n    # If the request is for a directory, ignores it\n    RewriteCond %{REQUEST_FILENAME} -f [OR]  \n    RewriteCond %{REQUEST_FILENAME} -l\n\n    RewriteRule ^[css|img|js|json].*$ - [L]\n    # Ignores hidden files\n    # Reroutes all requests to route.php with an action\n    RewriteRule ^(.*)$ route.php?action=$1 [QSA,L]\n\n\u003c/IfModule\u003e\n\n```\n\nIn the **[route.php](public/route.php)** file, I used an url parser to redirect the requests to the correct controller and method.\n\n```php\n\nfunction url_parse(string $url): array {\n    $url_data = explode('/', $url);\n    $data_array[ConfigApp::$ACTION] = $url_data[0];\n    $data_array[ConfigApp::$PARAMS] = isset($url_data[1]) ? array_slice($url_data, 1) : null;\n\n    return $data_array;\n}\n\n```\n\nSee more in the **[route.php](public/route.php)** file.\n\n## Frontend\n\nI went for a desing using **[Bootstrap 5](https://getbootstrap.com/)** as a framework and a little touch of my own colorscheme [styles.css](public/css/styles.css).\n\nI also used **[Smarty](https://www.smarty.net/)** as template engine.\n\n### Templates\n\n```tree\n\n├───📂 templates\n        - 📝 delete_modal.tpl\n        - 📝 edit_task.tpl\n        - 📝 error.tpl\n        - 📝 footer.tpl\n        - 📝 header.tpl\n        - 📝 task.tpl\n        - 📝 task_list.tpl\n\n```\n\n### Styles\n\nColorscheme for a dark theme purple style.\n\n```css\n\nhtml {\n    --bg-red: #c64646 !important;\n    --bg-red-darker: #b43737 !important;\n    --bg-purple: #a551c9 !important;\n    --bg-purple-darker: #9046b0 !important;\n    --bs-body-font-family: 'Roboto', sans-serif !important;\n}\n\n.dark {\n    background-color: #130c16;\n    color: #fff;\n}\n\n```\n\nSee more in the **[styles.css](public/css/styles.css)** file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejandrosuero%2Ftodo-app-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falejandrosuero%2Ftodo-app-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejandrosuero%2Ftodo-app-php/lists"}