Home
JohnLui edited this page Mar 16, 2015
·
11 revisions
Download it:
git clone https://github.com/TinyLara/TinyLara
cd TinyLara
Install dependences:
composer install
Run it:
cd public && php -S 127.0.0.1:3000
You will define all of the routes for your application in the config/routes.php
file:
// GET homepage
Route::get('/', 'HomeController@index');
// GET
Route::get('foo', function() {
echo "GET Foo!";
});
// POST
Route::post('foo', function() {
echo "POST Foo!";
});
// ANY: GET or POST
Route::any('foo', function() {
echo "ANY Foo!";
});
You can just return View::make('foo')
:
app/controllers/HomeController.php
:
return View::make('home')->with('article',Article::first())
->withTitle('TinyLara :-D')
->withFooBar('foo_bar');
app/views/home.php
:
<?php echo $title ?>
<?php echo $foo_bar ?>
$data = ['title'=>'你是谁??', 'email'=>'1@baiducom'];
$validator = $this->validate($data, [
'title' => 'required|min:3|max:4',
'email' => 'required|email',
]);
if ( !$validator->success ) {
foreach ($validator->errors as $error) {
echo $error.'<br>';
}
}