PHP code example of devkussema / semantica-app
1. Go to this page and download the library: Download devkussema/semantica-app 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/ */
devkussema / semantica-app example snippets
// routes/web.php
use Semantica\Core\Router;
Router::get('/', function() {
return view('home');
});
Router::get('/users/{id}', function($id) {
return view('users.show', ['id' => $id]);
});
// Route groups
Router::group(['prefix' => 'api'], function() {
Router::get('/users', 'UserController@index');
Router::post('/users', 'UserController@store');
});
// app/Controllers/UserController.php
namespace App\Controllers;
class UserController
{
public function index()
{
return view('users.index', [
'users' => ['John', 'Jane', 'Bob']
]);
}
public function show($id)
{
return view('users.show', ['id' => $id]);
}
}
// templates/default/users/index.php
$this->layout('layouts.main')
// Available everywhere after bootstrap
$debug = env('APP_DEBUG', false);
$config = config('app.name');
$view = view('welcome', ['name' => 'World']);
// config/database.php
return [
'default' => 'mysql',
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 3306),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
],
],
];