Skip to content

Experimental framework created in order to study the structures and functioning of the PHP language.

Notifications You must be signed in to change notification settings

juliorsantos/hyperframework

Repository files navigation

Hyper Framework

It's just for fun.

Clone this repo.

composer update

Configure the application env

cp .env.example .env

Set the .htaccess (apache file config)

cp .htaccess.example .htaccess

Default .htacess file

<IfModule mod_rewrite.c>
  RewriteEngine On

  # Don't change it.
  RewriteBase /public/

  # ROUTER WWW Redirect. (If you want WWW redirection)
  #RewriteCond %{HTTP_HOST} !^www\. [NC]
  #RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L]

  # ROUTER HTTPS Redirect (If you want HTTPS redirection)
  #RewriteCond %{HTTP:X-Forwarded-Proto} !https
  #RewriteCond %{HTTPS} off
  #RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L]

  # General route rewriting
  RewriteRule ^(.*)$ /public/index.php?route=/$1 [L,QSA]
</IfModule>

Create a simple page

Go to app/routes.php

$router->get("/", "Controllers\AppController:home");
$router->get("/404", "Controllers\AppController:error");

# Adding route
$router->get("/custom-route", "Controllers\AppController:customMethod");

Go to app/Controllers/AppController.php

And add this method

public function customMethod()
{
  $this->Template->render("customTemplate.twig");
}

Go to app/Views/customTemplate.twig

And add edit your page. (Example extending to layouts/main.twig)

{% extends 'layouts/main.twig' %}

{% block header %}
{% endblock %}

{% block content %}
  Your content here
{% endblock %}

{% block js %}
{% endblock %}

Now, access your server, example: http://localhost/custom-route

Check it.

References / Documentation

About

Experimental framework created in order to study the structures and functioning of the PHP language.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published