{"id":29291701,"url":"https://github.com/dconco/php_slides","last_synced_at":"2025-07-06T08:09:10.978Z","repository":{"id":210754855,"uuid":"726434710","full_name":"dconco/php_slides","owner":"dconco","description":"Slides to the next level in PHP using PhpSlides, a light MVC fast framework","archived":false,"fork":false,"pushed_at":"2024-07-20T02:28:22.000Z","size":631,"stargazers_count":21,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-11T13:41:10.063Z","etag":null,"topics":["api","php","php-framework","php-slides","phpslides","router","server","slides"],"latest_commit_sha":null,"homepage":"","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/dconco.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"dconco","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://www.buymeacoffee.com/dconco"]}},"created_at":"2023-12-02T11:45:10.000Z","updated_at":"2024-12-09T07:40:34.000Z","dependencies_parsed_at":"2023-12-21T22:33:21.650Z","dependency_job_id":"9538170e-cc9e-4d1d-a8ab-cad5955cb50c","html_url":"https://github.com/dconco/php_slides","commit_stats":null,"previous_names":["dconco/php_slides"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/dconco/php_slides","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dconco%2Fphp_slides","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dconco%2Fphp_slides/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dconco%2Fphp_slides/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dconco%2Fphp_slides/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dconco","download_url":"https://codeload.github.com/dconco/php_slides/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dconco%2Fphp_slides/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263868243,"owners_count":23522320,"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":["api","php","php-framework","php-slides","phpslides","router","server","slides"],"created_at":"2025-07-06T08:09:10.318Z","updated_at":"2025-07-06T08:09:10.972Z","avatar_url":"https://github.com/dconco.png","language":"PHP","funding_links":["https://ko-fi.com/dconco","https://www.buymeacoffee.com/dconco"],"categories":[],"sub_categories":[],"readme":"# PhpSlides\n\n**_PhpSlides_** is php framework mainly designed for already created foundation templates used in creating of `Router`, `Api` and `database management` 💫.\n\nUse **_PhpSlides_** in creating of Very based secured Router, Api \u0026 database, created inbuilt template database which accepts - `MySql` \u0026 `Sqlite` database 🔥✨ can also setup other database.\n\nIt has by default in preventing SQL injections, it prevents project from XXS attacks \u0026 CSRF 🔐.\n\nIt's a good practice for a beginner in Php to start with **_PhpSlides_**\n\n## How PhpSlides works:\n\n- With PhpSlides, all request coming from the server are redirecting to PhpSlides for verifing routing.\n  And checks if request matches the registered routes, else it returns a 404 Not Found Page 📌.\n\n- No request can access any files or folders in a PhpSlides project unless specified in routing 📌.\n- By default it returns 404 Not Found page if they navigates to any files or folders or any requests received if it hasn't been registered 📌.\n\n- Want to visit a file directly? It'll be Configured in the Slides config file, but can only access files in the public directory if specified 📌.\n- Also you can specify the types of files to access, or specify particular extensions that can be requested from each folders in the public directory or all folders 📌.\n- It accepts all types of files, Images, videos, audios, documents or plain texts 📌.\n\n- Read PhpSlides default codes and understand each codes function, codes are neat and readable 💯.\n\n## PhpSlides Examples \u0026 Explain\n\nFirstly, we create our Slides Project by executing this command in your Terminal\nif Composer is already installed.\n\n```bash\n   composer create-project dconco/php_slides slide_project\n```\n\nWhere the `slide_project` is the project name you which to create \u0026 it's the project directory.\nAnd it's going to create the project with the specified name at the target directory where you install it\n\nIf composer is not yet install. Install it by executing:\n\n```bash\n    pkg install composer\n```\n\n\u003cspan style=\"color:green\"\u003eAnd we're all setted.\u003c/span\u003e\n\nWe would open our project on vscode or PhpStorm or any other Php editors.\n\nLet's start our project on browser, you would setup \u0026 start the Apache server in your Xampp or any other Php server.\nIf you're using phone, you may use AwebServer for Php server.\nAnd open the host in your browser, you would see a default template.\n\n## Routing\n\nThere are different methods of Request Route.\nThis Route methods are used receiving request from the client side\n\n- GET Route\n- POST Route\n- PUT Route\n- UPDATE Route\n- DELETE Route\n- VIEW Route _(almost the same as GET)_\n- REDIRECT Route\n\n### Let's start with the View Routing\n\nOpen the `routes/route.php` file in your editor. Open the `routes` folder, the the `route.php` file.\nBy default you'll see a dashboard route been registered, you may remove it to start from scratch.\n\nLet's create a simple blog slides as example.\nSo we would register our routes, we would need a `Login Page`, `Register`, `Profile`, and `Posts Page`.\nLet's register pur routes in the `route.php` file and write example:\n\n```php (slides)\n    \u003c?php\n\n    include_once dirname(__DIR__) . \"/vendor/autoload.php\";\n\n    use PhpSlides\\Route;\n    use PhpSlides\\view;\n\n    Route::config();\n\n    Route::view(\"/login\", \"::Login\");\n\n    ?\u003e\n```\n\nThis example above is explained:\n\nFirstly we imported our autoload file from the vendor directory so we can use all our class names.\n\nWith `use PhpSlides\\Route` we use it in importing our Route class to use.\n\nThe `Route::config` function must be specified at the beginning of our codes.\nIt makes PhpSlides to configure our website Routes and makes it very secured\nwhich allows to to have access in configuring the routing and the requested paths.\n\nThe `Route::config` function takes 1 Boolean parameter which indicates whether to allow Logs request.\nBy default it's setted to true. So on each request it's writes the request header informations to the `.log` file.\n\nAnd the `Route::view` function allows you to create a view route.\n\nThe parameters passed to it, will be two, the first parameter specifies the route that should be requested to render the second parameter.\n\nThe second parameters render the files in the view directory which can be accessible with **::** (**_Double Colon_**) and the file name.\nAny files we creates in the view directory must be in the format `fileName.view.php` which the `fileName` is the name of the view file\nand the `.view.php` is the file extension, so PhpSlides will notice that it's a view file.\n\nSo let's create a new file called `Login.view.php` as we've registered it in the route.\nThen we can write a small example HTML code.\n\n```php (slides)\n    \u003chtml\u003e\n        \u003chead\u003e\n            \u003ctitle\u003eLogin Page\u003c/title\u003e\n        \u003c/head\u003e\n        \u003cbody\u003e\n            \u003ch2\u003eLogin Page\u003c/h2\u003e\n\n            \u003cinput type=\"email\" name=\"emai\" /\u003e\n            \u003cinput type=\"password\" name=\"password\" /\u003e\n\n            \u003cbutton type=\"submit\"\u003eLogin\u003c/button\u003e\n        \u003c/body\u003e\n    \u003c/html\u003e\n```\n\n### GET Route Method\n\nExample of GET Route method\n\n```php (slides)\n    \u003c?php\n\n    use PhpSlides\\Route;\n    use PhpSlides\\view;\n\n    Route::config();\n\n    Route::get(\"/login\", Route::view(\"::Login\"));\n\n    ?\u003e\n```\n\nYou see the difference between View \u0026 GET Route.\nIn view Route, you don't need to GET the view file with `Route::view`, you writes the view as a string in the 2nd parameter.\n\nBut in GET route, the 2nd parameters which is used as a callback function takes any types of code. eg, Strings, Array, Function.\nSince it returns it directly to the client side.\nWith GET routes, request method of the particular url to receive must be a GET request, so as all routes methods.\n\n**_GET Route with Closure Function method_**\n\n```php (slides)\n    Route::get(\"/login\", function() {\n        return Route::view(\"::Login\");\n    });\n```\n\nIt returns the Login view page, we can return any php values to the browser.\n\nAll routes methods has second parameters as callback function which takes function methods or any other methods.\n\n**_GET Route method with url Parameters with Closures_**\n\n```php (slides)\n    Route::get(\"/posts/{id}\", function(int $id) {\n        return \"Posts ID = \" . $id\n    });\n```\n\nThis above example register a new GET route with /posts request which receive GET request with a function closure parameters of ID.\nIf the request was /posts/2 then it'll return \"Posts ID = 2\" it gets the ID value and send it to the client side/browser.\n\n## POST Route Method\n\nExample of POST Route method\n\n```php (slides)\n    \u003c?php\n\n    use PhpSlides\\Route;\n    use PhpSlides\\view;\n\n    Route::config();\n\n    Route::post(\"/add_user\", ());\n\n    ?\u003e\n```\n\nIt calls the POST method, it indicates that the POST route function can only be executed if the REQUEST_METHOD is a POST request.\nAnd can be used in like submitting form data.\n\nThe second parameters is empty, can return a JSON format,\nbecause POST method is normally used in sending a POST request that returns data in a JSON formats, 2nd parameters can contain any formats for a callback function\n\nThat's how the rest Route method is.\n\n## PUT Route Method\n\nExample of PUT Route method\n\n```php (slides)\n    Route::put(\"/user\", ());\n```\n\nPUT method is just like a POST request, in adding informations or data to a specific file or database.\n\n## UPDATE Route Method\n\nExample of UPDATE Route method\n\n```php (slides)\n    Route::update(\"/user/{id}\", ());\n```\n\nUPDATE method is normally used in updating information like in database.\n\n### DELETE Route Method\n\nExample of DELETE Route method\n\n```php (slides)\n    Route::delete(\"/user/{id}\", ());\n```\n\nDELETE method is normally used likely in deleting informations in the database.\n\n### ANY Route Method\n\nExample of ANY Route method\n\n```php (slides)\n    Route::any(\"/user/{id}\", ());\n```\n\nWith `Route::any()` method can be used if you want to accept all types of request.\nCan be either POST, GET, PUT, UPDATE or DELETE, depending on the requested route method.\n\n## Create NotFound Errors Route\n\nExample of NotFound Route method\n\n```php (slides)\n    Route::any(\"*\", Route::view(\"::errors::404\"));\n```\n\nIn this above NotFound example, we created an ANY Route\nand make the first parameter to be `*`\nwhich indicates to return whenever there's no routes matches the requested URL.\n\nThe NotFound route should be at the ending of the registered routes,\nso it can be executed when all above routes are mismatched.\n\nAnd in the second parameter, we navigates to `view` folder\nand created a folder named `errors` inside the `view` directory,\nthen create a page called `404.view.php`\n\n## Multiple Route URL Rendering\n\nYou can creates a multiple routes url that'll render a page or a function.\n\nCreate multiple URLs with array and list of URLs in it.\nCan use any route methods.\n\n**_NOTE:_** You cannot use multiple URLs when using routes parameters with {} curly braces\n\n```php (slides)\n    Route::view([\"/\", \"/index\", \"/dashboard\"], \"::dashboard\");\n```\n\nThis example explains that whenever the requested URL matches the URLs specified in the array,\nand it renders the `dashboard.view.php` in the browser.\nAll route methods accepts multiple URL. Can also create multiple URL for 404 page.\n\n## Route Controller with Closures\n\n`PhpSlides` allows you to be able to access Route Parameters keys in class controller.\n\nYou can use any Route Methods for Routing Controller except View method.\nLet's go with GET method.\n\nWe do create our simple class component in the `Controller` directory at the root directory of your project.\n\nNavigates to the `Controller` directory and create a controller name of your choice but must be in this format `ClassName` + `Controller.php` which should be `ClassNameController.php`.\n\nSo let's create a new Controller called `UserController.php`.\nLet's navigates to the created file and write some codes in it.\n\n```php (slides)\n    \u003c?php\n\n    namespace PhpSlides\\Controller;\n\n    final class UserController extends Controller\n    {\n        public function __invoke(int $id) {\n            return \"\u003ch2\u003eGet User with ID = {$id}\u003c/h2\u003e\";\n        }\n    }\n\n    ?\u003e\n```\n\nIn this example above, we created a file called `UserController.php` in the `/controller` folder.\n\nAnd we created a namespace for the class controller that'll be used in calling the class.\nWe created the class called `UserController` and extends it to the `Controller` class,\nwhich allows you to access some protected functions.\n\nMake sure after every created class components which has a namespace you should run this below command for autoloading of each classes.\n\n```bash\n    composer slides-refresh\n```\n\nThe final keywords in the class describes that the class should be final and cannot be extended to another class,\nyou may remove it if the class should be extended.\n\nAnd we create our public function called \\_\\_invoke which gets the closure parameter in route,\nthat'll be used to get the url params and returns value for the callback function.\nSo it gets the closure $id parameters, and describes it as an integer using the `int` before the param name.\n\nLet's register the user routes and make it to be GET route, can make it any type of route request depending on the usage.\n\n```php (slides)\n    \u003c?php\n\n    use PhpSlides\\Route;\n    use PhpSlides\\Controller\\UserController;\n\n    Route::config();\n\n    Route::get(\"/user/{id}\", [ UserController::class ]);\n\n    ?\u003e\n```\n\nIn this above example, we already created a class called `UserController`,\nAnd we created a GET route method which has a URL parameter of `id`.\n\nThen we render the `UserController` class, which the `id` parameter has been sent to the `UserController` class with the `__invoke` function.\n\n### Route Controller with Class Method\n\nIn our class controller, we can also create multiple methods for different Route request.\n\n```php (slides)\n    \u003c?php\n\n    final class UserController extends Controller\n    {\n        public function __invoke() {\n            return \"\u003ch2\u003eInvoked User Successful. Receieved all users successfully.\u003c/h2\u003e\";\n        }\n        public function User($id) {\n            return \"\u003ch2\u003eReceived an ID - $id for a user.\u003c/h2\u003e\";\n        }\n    }\n\n    ?\u003e\n```\n\nIn the `UserController` we created another method called `User()` which takes one parameter as `$id` for the `id` URL request parameter.\n\nSo let's use the `User()` class method in the route.\n\n```php (slides)\n    Route::get(\"/user\", [ UserController::class ]);\n    Route::get(\"/user/{id}\", [ UserController::class, 'User' ]);\n```\n\nIn first function doesn't has a URL parameter, because in this case we're returning all available users, not each user.\n\nAnd we created the second function as `/user/{id}`, that means we passed the `id` URL parameter into the `User()` route method.\n\nTo use the `User()` method by passing the method name which is `User` as string into the route controller array, at the 2nd index of the array, can only take two array values.\n\nCan add as many methods as possible, and many URL parameters as you can.\n\n### Multiple URL Parameters with Closures\n\nExample below for creating multiple URL parameters:\n\n```php (slides)\n    Route::get(\"/user/{id}/post/{post_id}\", function($user_id, $post_id)\n    {\n        return \"User ID = $user_id \u0026 Post ID = $post_id\";\n    });\n```\n\nIt has two URL parameters called `id` and `post_id` for user id and post id, then we gets the URL parameters in the closure function parameter.\nSame thing as route controller method.\n\nBut make sure the function closure parameters variable cannot be the same else it might turns conflict, but the URL parameters may be the same.\n\n## PhpSlides Configurations\n\nConfigurations in PhpSlides, makes you have full access in configuring the way request can be sent/received in routings.\nAnd routing configurations can be setup in the `phpslides.config.json` file.\n\nBy default everywhere in the web will be blank even though they navigates to any pages. So the web routing is used to add pages to the web if they follow any links, it'll return the page for the URL. And if setupped `Not Found page`, it'll be used whenever the page does not exist.\n\nBy default if they open any urls to any path of the page, the web will be blank unless added the `Not Found page` so it'll return it, because to make your website secured they can only access the part you want them to access.\n\nAnd the configurations in PhpSlides makes it easy in allowing you to configure the part a user can view, to make a very secured website..As they can only view any files in the public folder, but cannot view the folders there apart from Routing.\n\n**\\_Example of Configuration in PhpSlides**\n\nOpen the `phpslides.config.json` at the root directory of your project.\n\n```json\n{\n  \"charset\": \"UTF-8\"\n}\n```\n\nThis above example specifies the charsets to be used in returning all files and routing pages to the brower.\nBut can change it at anytime with PHP code, if you want some part to be changed.\n\n```json\n{\n  \"public\": {\n    \"/\": [\"*\"]\n  }\n}\n```\n\nWe added a `public` key in the json file, which specifies that inside the `public` directory, the files and nested files in folders it can access\n\nWe added the `/` key which specifies the root of the `public` directory. So we added it has `*` _(Asterisk)_. Which specifies to access all files in the root of the `public` directory. And we can specify any type of extensions they can access, even though the file exist and they try to access the file that the extension are not available in the cconfiguration, it'll return a `Not Found page`. They can write multiple extesnsions in the array. And can also write `image` whereby they can access all images, `video` or `audio`.\n\n```json\n    \"/\": [ \"image\", \"audio\", \"video\" ]\n```\n\nOn each nested folders inside the `public` directory will be specified as an array of extensions in the config file.\nAnd if you want to allow all nested folders, you would just specify the folder in the json file and the extension it can allow in all nested directories.\n\nLike let's say directories are in this formats:\n\n```text\n    public:\n        assets:\n            image.jpg\n            file.pdf\n            vendor:\n                bootstrap.min.js\n        images:\n            image.png\n            image1.jpg\n            file.html\n```\n\nSo this example is explained:\nIn the `public` directory we have `assets` and `images` folder. so in the `assets` folder we have 1 image, 1 PDF file and 1 `vendor` folder which contain `bootstrap.min.js`. So if we want to configure it::\n\n```json\n{\n  \"public\": {\n    \"assets\": [\"jpg\", \"js\"],\n    \"images\": [\"image\", \"video\"]\n  }\n}\n```\n\nIn this example we only created configurations for the `assets` and `images` directory, so all files and folders in the `assets` directory will use the extensions added in the `assets` directory which specifies that in this example, the `js` extension specified will be allowed also in the `vendor` folder, or we add the `vendor` key to the json file.\n\nSo as we configure the `assets` directory they can only access the `jpg` file and the `js` file in the `vendor` folder.\n\nFor the `images` directory we specified that it can only access the any files that are `image` or `video`, so it allows the 2 files there which are `png` \u0026 `jpg` and return `Not Found page` whenever they tries to access the `file.html` which extension is not added.\n\n### View Public Files in Web\n\nTo view all files that are in `public` directory with files in nested folders. You woudn't add the `public` folder before getting files, it'll return `Not Found page`. So like the above example, to access the file in the `assets` folder. We would follow the url: `http://localhost:8000/assets/image.jpg` and not `http://localhost:8000/public/assets/image.jpg`.\nAnd if files are in the root directory of the project, it would be accessed directly after the host url: `http://localhost:8000/image.jpg`.\n\n# Version 1.1.0\n\nIn this version, slides provides way in dealing with view page 🔥\nCreate your view template file in the `views` directory, in this format `fileName` + `.view.php` extension. which is `fileName.view.php`\n\nPhpSlides created some special view syntax.\n\n- @view\n- ::view\n- ::root\n- \u003cinclude !/\u003e\n- `\u003c? ?\u003e`\n\nLets get this started..\n\n```php (slides)\n  \u003c!DOCTYPE html\u003e\n  \u003chtml\u003e\n    \u003c!-- Php codes if needed --\u003e\n    \u003c?\n\n    ?\u003e\n\n    \u003chead\u003e\n      \u003c!-- Meta Tags Info --\u003e\n      \u003ctitle\u003ePage Title\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n      \u003c!-- Body contents --\u003e\n    \u003c/body\u003e\n  \u003c/html\u003e\n```\n\nIn a view template page where we writes HTML codes, PHP tag should not starts the file,\ninstead write the php tag and codes inside the `\u003chtml\u003e` tag or any other places apart from the starting,\nshould always start HTML documents with the `\u003chtml\u003e` tag and not `\u003c?php` tag\n\nThe `\u003c? ?\u003e` tag in the view template is short php tag used in writing short php codes.\nlike using if statement, or echoing data to the html page. Example codes:\n\n```php (slides)\n  \u003cbody\u003e\n    \u003c? if ($user): ?\u003e\n      \u003ch1\u003eHello \u003c? @view $user ?\u003e\u003c/h1\u003e\n    \u003c? else: ?\u003e\n      \u003ch1\u003eHello Guest\u003c/h1\u003e\n    \u003c? endif; ?\u003e\n\n    \u003cp\u003e\n      \u003c? @view 'welcome to our blog spot!' ?\u003e\n    \u003c/p\u003e\n  \u003c/body\u003e\n```\n\nThis example is explained as: in the body element we check if a user returns true then it'll add the `h1` element with the text Hello with the user variable value which is returned using the @view keyword in slides.\nElse it'll return and `h1` element with text Hello Guest\nIn the `\u003cp\u003e` tag we wrote php codes which uses the `@view` keyword to return the string/value to the `\u003cp\u003e` element.\n\n**::view \u0026 ::root**\n\nThe `::view` is just a word written only in the view template files which return the root location after the server name in the project starting from the `/`. Usually used to link public files.\nAnd the `::root` is returning the root location of your project and not has the `::view`, `::root` is used in php in including any files of the project,\nbut `::view` can just access only what the browser/client side can acces, but cannot access any files in project when not in `public` directory.\n\nNow let's imagine we have images we would access in the public directory and extra php file we would need to include in the view page.\n\n```php (slides)\n  \u003cbody\u003e\n    \u003c? include '::root/components/extraFile.php' ?\u003e\n\n    \u003cdiv\u003e\n      \u003cimg src=\"::view/assets/icon.png\" alt=\"Icon\" /\u003e\n    \u003c/div\u003e\n  \u003c/body\u003e\n```\n\nIn this case the root of the project is indicated as `::root` and inside the project we created a folder called `components` and new file called `extraFile.php` for any php codes to include in the view page.\n\nThe `::view` is the root location of the server host, so let's imagine the host url as `http://localhost:8000/` so it's indicated as `::view` and normally in slides,\nall files and folders in `public` directory are extended in the root of the url as `::view/` and not `::view/public`\n\nSo the url as `::view/assets/icon.png` in the `public` directory, created a `assets` folder and `icon.png` image.\n\n## SLIDES_INCLUDE\n\nSlides provides way for you to include another view template file to a view page, and not only a php files.\n\n**2 ways of including view page**\n\n- Using the `\u003cinclude !/\u003e` html tag\n- Using the `slides_include` php function\n\nWith the `\u003cinclude !/\u003e` html tag, you can include other php/view page to the current view page.\nWhich allows you to write slides view template in other files to include. And can also include any other php file located anywhere in the project.\n\n```html\n\u003cbody\u003e\n  \u003cinclude path=\"::root/components/extraFile.php\" ! /\u003e\n  \u003cinclude path=\"::root/views/viewPage.view.php\" ! /\u003e\n\u003c/body\u003e\n```\n\nSo in the first tag we included a php file located at the `components` directory.\nAnd the second tag we included a view template file located in the `views` directory.\nAnd can only use the `\u003cinclude !/\u003e` tag in a view template page.\n\n**slides_include**\n\nThis function provides a way for you to include view files in any php file \u0026 not only on the view template page.\n\n```php (slides)\n  \u003c? @view slides_include('::root/comp/extraFile.php') ?\u003e\n  \u003c? @view slides_include('::root/views/page.view.php') ?\u003e\n```\n\n# Version 1.2.0\n\n## API\n\nPhpSlides realeased APIs in -v1.2.0, which allows you to work with API in your project.\nAPI is just like Route but it's rendering data back to the request and not the browser.\nSlides provide the `Api` function which allows you to register an API route. And setted up the API controller in the `web.php` file.\nRegister your new API route in the `routes/api.php` file\n\n```php (slides)\n  \u003c?php\n    use PhpSlides\\Api;\n\n    Api::get();\n    Api::post();\n    Api::put();\n    Api::patch();\n    Api::update();\n    Api::delete();\n  ?\u003e\n```\n\nIn the above example blocks of code, we create APIs and those are the API request method that are available in the API.\nThe `Api` function only takes 2 parameters, the API route url and the second parameter is the controller class method.\n\n**_NOTE_** that before you can create API, make sure you setted up the `Route::config()` function in the `route.php` file even though you're not to use the web Route.\n\nLet's create an API for the given request route `\"/api/users\"` with a POST method which would show the list of available users in a database.\nAnd create another route `\"/api/users/{id}\"` also a POST method which would show a particular user by the given id.\n\n```php (slides)\n  \u003c?php\n    use PhpSlides\\Api;\n\n    Api::post(\"/api/users\");\n    Api::post(\"/api/users/{id}\", @user);\n  ?\u003e\n```\n\nSo in the first Api we didn't provide a second parameter for the method to use which by default is `__invoke` method.\nAnd in the second we use the `@user` which declears the `user` method of the same controller class. The `@` target the method name of the controller class.\n\nLet's first create our controller class in the `Controller/Api` directory. Let's name it `UserController`.\nIn our controller names, it is must the `Controller` to end a file, which describes a controller file.\n\n```php (slides)\n  \u003c?php\n\n  namespace PhpSlides\\Controller;\n\n  final class UserController extends Controller\n  {\n    function __invoke() {\n      $response = ['data' =\u003e 'We have gotten all users id successful'];\n      return json_encode($response);\n    }\n\n    function user(int $id) {\n      $response = ['data' =\u003e 'The particular user id = $id'];\n      return json_encode($response);\n    }\n  }\n\n  ?\u003e\n```\n\nIn the `UserController` class we created the two functional methods and retun an encoded json format.\n\nNot yet done.. We need to register each API routes url for controller class in the `src/web.php` file.\n\n```php (slides)\n  \u003c?php\n\n  use PhpSlides\\Controller\\UserController;\n\n  return [\n    '/api/users' =\u003e UserController::class,\n    '/api/users/{id}' =\u003e UserController::class\n  ];\n\n  ?\u003e\n```\n\nWe returned the register API routes now API is ready to be consumed ❤️💯.\n\n**_HURRAY as you enjoy using PhpSlides!!!_**\n\n**_More functions are coming in the next versions_**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdconco%2Fphp_slides","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdconco%2Fphp_slides","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdconco%2Fphp_slides/lists"}