PHP code example of dconco / php_slides

1. Go to this page and download the library: Download dconco/php_slides library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dconco / php_slides example snippets

 (slides)
    

    e;
    use PhpSlides\view;

    Route::config();

    Route::view("/login", "::Login");

    
 (slides)
    <html>
        <head>
            <title>Login Page</title>
        </head>
        <body>
            <h2>Login Page</h2>

            <input type="email" name="emai" />
            <input type="password" name="password" />

            <button type="submit">Login</button>
        </body>
    </html>
 (slides)
    

    use PhpSlides\Route;
    use PhpSlides\view;

    Route::config();

    Route::get("/login", Route::view("::Login"));

    
 (slides)
    Route::get("/login", function() {
        return Route::view("::Login");
    });
 (slides)
    Route::get("/posts/{id}", function(int $id) {
        return "Posts ID = " . $id
    });
 (slides)
    

    use PhpSlides\Route;
    use PhpSlides\view;

    Route::config();

    Route::post("/add_user", ());

    
 (slides)
    Route::put("/user", ());
 (slides)
    Route::update("/user/{id}", ());
 (slides)
    Route::delete("/user/{id}", ());
 (slides)
    Route::any("/user/{id}", ());
 (slides)
    Route::any("*", Route::view("::errors::404"));
 (slides)
    Route::view(["/", "/index", "/dashboard"], "::dashboard");
 (slides)
    

    namespace PhpSlides\Controller;

    final class UserController extends Controller
    {
        public function __invoke(int $id) {
            return "<h2>Get User with ID = {$id}</h2>";
        }
    }

    
 (slides)
    

    use PhpSlides\Route;
    use PhpSlides\Controller\UserController;

    Route::config();

    Route::get("/user/{id}", [ UserController::class ]);

    
 (slides)
    

    final class UserController extends Controller
    {
        public function __invoke() {
            return "<h2>Invoked User Successful. Receieved all users successfully.</h2>";
        }
        public function User($id) {
            return "<h2>Received an ID - $id for a user.</h2>";
        }
    }

    
 (slides)
    Route::get("/user", [ UserController::class ]);
    Route::get("/user/{id}", [ UserController::class, 'User' ]);
 (slides)
    Route::get("/user/{id}/post/{post_id}", function($user_id, $post_id)
    {
        return "User ID = $user_id & Post ID = $post_id";
    });
 (slides)
  <!DOCTYPE html>
  <html>
    <!-- Php codes if needed -->
    <?

    
 (slides)
  <body>
    <? if ($user): 
 (slides)
  <body>
    <? 
 (slides)
  <? @view slides_
 (slides)
  
    use PhpSlides\Api;

    Api::get();
    Api::post();
    Api::put();
    Api::patch();
    Api::update();
    Api::delete();
  
 (slides)
  
    use PhpSlides\Api;

    Api::post("/api/users");
    Api::post("/api/users/{id}", @user);
  
 (slides)
  

  namespace PhpSlides\Controller;

  final class UserController extends Controller
  {
    function __invoke() {
      $response = ['data' => 'We have gotten all users id successful'];
      return json_encode($response);
    }

    function user(int $id) {
      $response = ['data' => 'The particular user id = $id'];
      return json_encode($response);
    }
  }

  
 (slides)
  

  use PhpSlides\Controller\UserController;

  return [
    '/api/users' => UserController::class,
    '/api/users/{id}' => UserController::class
  ];

  
bash
   composer create-project dconco/php_slides slide_project
html
<body>
  <th="::root/views/viewPage.view.php" ! />
</body>
` tag

The `<?