What is sFire?

sFire is a secure, fast and lightweight PHP Framework.

Enables you to quickly develop a (multi language) website with the advantage of the Model, View and Controller pattern. Manage all your links in one location called “routes.php” and with the build in Template parser you can create pages that are clear and easily to maintain.

 

Example simple registration form:

The Controller:

class ControllerContact extends Controller {

    public function __start() {

        View :: load('header');
        View :: load();
        View :: load('footer');
    }

    public function index() {

        Validator :: make();
        Validator :: rule('required', ['name', 'email']);
        Validator :: rule('notEmpty', ['name', 'email']);
        Validator :: rule('email', 'email');
        Validator :: rule('notInDatabase', 'email', $this -> Registration, 'checkEmail');

        if(Validator :: fails()) {
            Template :: assign('errors', Validator :: $errors);
        }
    }
}

 

The Model:

class ModelRegistration extends Model {

    public function checkEmail($email = false) {

        return Database :: num_rows(
            'email', 'users', 'email = ?', array($email)
        );
    }
}

 

The View:

@if($errors)
    <ul>
        @foreach($errors as $error)
            <li>{{{ $error }}}</li>
        @endforeach
    </ul>
@endif

<form action="{{{ route('registration') }}}" method="post">
    {{ Form :: text('name') }}
    {{ Form :: text('email') }}
    {{ Form :: submit('submit', 'Submit!') }}
</form>

Comments are closed.