A simple PHP framework

dev-master 2019-11-07 07:39 UTC

README

A simple PHP framework inspired by Laravel

CircleCI Scrutinizer Code Quality CircleCI

Requirements

Vertex makes use of Composer to autoload its dependencies. Be sure to run the following command after downloading the framework.

composer install

Gulp

Once all the dependencies have been installed you can get started using Gulp. This step is completely optional and you can skip this if your project doesnt require a build step!

Firstly, ensure that you have both Node.js and NPM are installed on your machine. You can check this by running the -v command:

node -v
npm -v

Next, you will need to pull in Gulp as a global NPM package:

npm install --global gulp-cli

After that you will then need to run the npm install command to pull in all of the Gulp dependencies

npm install

Finally run the gulp commmand on the root of your project.

Configuration

All configuration options are specified in the .env file in the root directory. By default you will get an example file to get you started.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=databasename
DB_USERNAME=root
DB_PASSWORD=root

There is also the option of manually declaring your setting in the /config directory. Simply go into any of the files in this directory and manually replace the getenv() functions with your desired configuration.

You can easily access any of your config options in Vertex by using the Config::get() method. Supply a string to the method (eg Config::get('database')) and it will return an array of all the values specified in that file, in this case it would be /config/database.php.

Routes

Vertex uses FastRoute for all its routing needs. Routes are stored in the app/routes.php file. Please visit the following repo for full documentation https://github.com/nikic/FastRoute.

Here are some example routes:

/* standard routes */
$route->get('/test', 'ControllerName@MethodName');
$route->post('/test', 'ControllerName@MethodName');
$route->put('/test', 'ControllerName@MethodName');
$route->delete('/test', 'ControllerName@MethodName');

/* route with parameters */
$route->get('/test/{parameter}', 'ControllerName@MethodName');

/* route with closure */
$route->get('/test', function(){
  return 'Test!';
});

/* route group */
$route->addGroup('/admin', function ($route) {
    $route->get('/dashboard', 'AdminController@dashboard'); // admin/dashboard
    $route->get('/pages', 'AdminController@pages');         // admin/pages
    $route->get('/posts', 'AdminController@posts');         // admin/posts
});

Templating

Vertex uses Laravels fantastic Blade templating engine. Views are stored in the app/resources/views/ directory and must have the file extension of .blade.php. Please visit https://laravel.com/docs/5.3/blade for full documentation.

Here is an example blade template:

<html>
    <head>
        <title>App Name - @yield('title')</title>
    </head>
    <body>
        @section('sidebar')
            This is the master sidebar.
        @show

        <div class="container">
            @yield('content')
        </div>
    </body>
</html>