PHP code example of clintonnzedimma / woski

1. Go to this page and download the library: Download clintonnzedimma/woski 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/ */

    

clintonnzedimma / woski example snippets


   // index.php (or public/index.php)
    Global middleware example
   // $app->use([$demoMW->handle]);

   // Basic route
   $app->get('/', [$homeController->index]);

   // Grouped routes
   $app->use('/example', [$demoMW->foo], _import('routes/example.routes.php'));

   // 404 handler
   $app->error(['GET','POST','PUT','PATCH'], function($req, $res) {
       $res->sendStatus(404);
       return $res->json(['error'=>'Not found']);
   });

   $app->start();
   

  config('app.name');   // "WoskiPHP"
  config('app.debug');  // true/false
  

$errors = validate($req->body, [
  'email'    => ' ($errors) {
  return $res->json(['errors'=>$errors], 422);
}

if ($req->hasFile('avatar') && $req->isImage('avatar')) {
  $file = $req->files['avatar'];
  move_uploaded_file($file['tmp_name'], 'uploads/'.$file['name']);
  return $res->json(['message'=>'Uploaded']);
}
bash
   php woski --run           # default port 3000 or WOSKIPHP_PORT
   php woski --run --port=8xxx
   
bash
   php woski --make:controller UserController
   php woski --make:middleware AuthMiddleware
   php woski --make:model User --table=users