PHP code example of jabranr / lassi

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

    

jabranr / lassi example snippets


$app->get('/hello', function() use ($app) {
	$app->response->write('Hello World');
});

$app->get('/goodbye', function() use ($app) {
	return $app->render('goodbye.php');
});

class WelcomeController extends Lassi\App\Controller {
	...

	public function goodbye() {
		return $this->app->render('goodbye.php');
	}
}

$app->get('/goodbye', 'Lassi\Controller\WelcomeController:goodbye');

class WelcomeController extends Lassi\App\Controller {
	...

	public function makeUserTable() {
		Illuminate\Database\Capsule\Manager::schema()->create('users', function($table) {
			$table->increments('id');
			$table->string('name');
			$table->string('email')->unique();
			$table->timestamps();
		});
	}
}

class WelcomeController extends Lassi\App\Controller {
	public function __construct() {
		parent::__construct(LassiLassi::getInstance());
		$this->useModel('user');
	}
}

class WelcomeController extends Lassi\App\Controller {
	...

	public function create() {
		$user = new Lassi\Model\User;
		$user->name = 'Jabran Rafique';
		$user->email = '[email protected]';
		$user->save();
	}
}

class WelcomeController extends Lassi\App\Controller {
	...

	public function goodbye() {
		$user = Lassi\Model\User::find(1);
		return $this->app->render('goodbye.php', array('user' => $user));
	}
}