SilverEngine
Digital Solutions

Get Started

You can follow this documantation to create your first blog

Create controller resource

What is resource?

Resource is predefined template different files that generate for you in the App/ folder.

  1. Make new Controller
  2. Make new Modelr
  3. Make new Veiw
  4. Add new Route

After executing command below you can open your webpage in browser by the {name} you put in the paramater

php silver make resource {name}

Advanced:

For advanced you can customize App/Templates files do every time you run the command will predefine as you need

Advanced options - Controller

<?php echo '<?php'; ?>

namespace App\Controllers;

use Silver\Core\Controller;
use Silver\Http\View;

/**
* {{{$name}}} controller
*/
class {{{ucfirst($name)}}}Controller extends Controller
{
    protected $name = "{ $name}}";
    public function get()
    {
        return View::make('{{ $name }}')->with('name', $this->name);
    }

    public function post()
    {
        echo 'Method: post';
    }

    public function put()
    {
        echo 'Method: put';
    }

    public function delete()
    {
        echo 'Method: delete';
    }
}

Examples

App/Controllers/BlogController.php
<?php

namespace App\Controllers;

use Silver\Core\Controller;
use Silver\Http\View;

class BlogController extends Controller
{
    public function welcome()
    {
        return View::make('welcome.index');
    }
}
App/Models/Blog.php
<?php

namespace App\Models;
use Silver\Database\Model;
/**
 * Blog Model
 */
class Users extends Model
{
    protected static $_table = 'blog'
    protected $hidden = [];
}
App/Routes/Web.php
Route::get('/blog', 'Blog@index', 'blog', 'public');
App/Views/blog.ghost.tpl
{{ extends('layouts.master') }}
#set[content]
    Welcome to Blog welcome page
#end