PHP code example of phpdominicana / lightwave

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

    

phpdominicana / lightwave example snippets




// routes/web.php

use Phpdominicana\Lightwave\Controllers\HelloController;
use Phpdominicana\Lightwave\Controllers\HomeController;
use Phpdominicana\Lightwave\Router;

/** @var Router $router */

// Example: GET route with a parameter
$router->get('/hello/{name}', [HelloController::class, 'index']);

// Example: GET route for the homepage
$router->get('/', [HomeController::class, 'index']);

// Example: POST route
// $router->post('/users', [UserController::class, 'store']);

// Example: PUT route
// $router->put('/users/{id}', [UserController::class, 'update']);

// Example: DELETE route
// $router->delete('/users/{id}', [UserController::class, 'destroy']);

    // In HelloController.php
    public static function index(string $name): Response
    {
        // $name will contain the value from the URL
        return new Response("Hello {$name}");
    }
    

    // In HomeController.php
    use Pimple\Psr11\Container;
    use Symfony\Component\HttpFoundation\Response;

    public static function index(Container $container): Response
    {
        $view = $container->get('view'); // Assuming 'view' service is registered
        return new Response($view->render('welcome.twig'));
    }
    

'providers' => [
        \Phpdominicana\Lightwave\Providers\AppServiceProvider::class,
       \Phpdominicana\Lightwave\Providers\TwigServiceProvider::class,
         \Phpdominicana\Lightwave\Providers\RouteServiceProvider::class,
         \Phpdominicana\Lightwave\Providers\EloquentServiceProvider::class
    ],


 
namespace Phpdominicana\Lightwave\Models;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    protected $table = 'users';
    protected $fillable = ['name', 'email', 'password'];
}