Last update: 1 January 2019 | version 1.0.0
Thank you for purchasing QxAPHP application. If you have any questions that are beyond the scope of this documentation, please feel free to contact me on that page.

1. Requirements Back to top

To make application working you need:
  1. Server with PHP 7+
  2. PDO Extension
  3. Rewrite Module for Apache
Also, for some functions you will need:
  1. Composer for updating 3rd party components
  2. CRON for using scheduled email notifications
  3. SMTP or Mailgun for sending emails

2. Installation Process Back to top

  1. Upload all files to your web server through FTP (Usually public_html folder).
  2. Create new database, which will be used by application.
  3. Import the qxaphp.sql file from the root folder into your MySQL database using the import function available in MySQL.
  4. With any text editor open the following file located inside the 'App' folder: Config.php, and set your MySQL settings:
    const DB_NAME = '';  <- Your database name (from 2nd step)
    const DB_USER = '';  <- Your database user
    const DB_PASSWORD = '';  <- Your database password
    							
  5. Set the CHMOD to 777, 775 or 755 (depending on the server configuration) to the following folders: '/logs', '/public/media/images/'.
  6. If you are using Composer's version - run:
    composer install
    							

3. Configuration Back to top

The default email for the Admin is "admin@admin.com", and the password is "admin" without quotes. You need to change it after signing in.


  • Add Topics
  • Application will not allow user to work with it without at least 5 topics added. Sign in using admin account and add at least 5 topics to start using the app.

    You can add "disabled" topics, which will not be available for users, but will be visible only in admin panel, until be set to active.


  • Update Configuration
  • Is recommended to change values for HASH_TOKEN_KEY and SECRET_TOKEN_KEY, located in 'App\Config.php' file. You can generate new one here - https://randomkeygen.com/. Use Hash token key (256 bit key) when will generate new keys. Another settings are available in admin account, in admin dashboard.

    You can access the settings in your code like this: Config::DB_HOST. You can add your own configuration settings in that file.

    Also, you can access any website setting from database from Controller / Model (By adding use App\Config.php;) - Config::getValues('app_name'); and Views - {{ settings.app_name }}.


    4. MVC Pattern Back to top

    Routers

    The Router translates URLs into controllers and actions. Routes are added in the front controller. A sample home route is included that routes to the index action in the Home controller.

    Routes are added with the add method. You can add fixed URL routes, and specify the controller and action, like this:

    $router->add('', ['controller' => 'Home', 'action' => 'index']);
    $router->add('posts/index', ['controller' => 'Posts', 'action' => 'index']);
    					

    Or you can add route variables, like this:

    $router->add('{controller}/{action}');
    					

    In addition to the controller and action, you can specify any parameter you like within curly braces, and also specify a custom regular expression for that parameter:

    $router->add('{controller}/{id:\d+}/{action}');
    					

    You can also specify a namespace for the controller:

    $router->add('admin/{controller}/{action}', ['namespace' => 'Admin']);
    					

    Controllers

    Controllers respond to user actions (clicking on a link, submitting a form etc.). Controllers are classes that extend the Core\Controller class.

    Controllers are stored in the App/Controllers folder. A sample Home controller included. Controller classes need to be in the App/Controllers namespace. You can add subdirectories to organise your controllers, so when adding a route for these controllers you need to specify the namespace (see the routing section above).

    Controller classes contain methods that are the actions. To create an action, add the Action suffix to the method name. The sample controller in App/Controllers/Home.php has a sample index action.

    You can access route parameters (for example the id parameter shown in the route examples above) in actions via the $this->route_params property.


    Action filters

    Controllers can have before and after filter methods. These are methods that are called before and after every action method call in a controller. Useful for authentication for example, making sure that a user is logged in before letting them execute an action. Optionally add a before filter to a controller like this:

    /**
     * Before filter. Return false to stop the action from executing.
     *
     * @return void
     */
    protected function before()
    {
    }
    					

    To stop the originally called action from executing, return false from the before filter method. An after filter is added like this:

    /**
     * After filter.
     *
     * @return void
     */
    protected function after()
    {
    }
    					

    Views

    Views are used to display information (normally HTML). View files go in the App/Views folder. Views can be in one of two formats: standard PHP, but with just enough PHP to show the data. No database access or anything like that should occur in a view file. You can render a standard PHP view in a controller, optionally passing in variables, like this:

    View::render('Home/index.php', [
        'name'    => 'QxAPHP',
        'links'   => ['home', 'stream', 'users']
    ]);
    					

    The second format uses the Twig templating engine. Using Twig allows you to have simpler, safer templates that can take advantage of things like template inheritance. You can render a Twig template like this:

    View::renderTemplate('Home/index.html', [
        'name'    => 'QxAPHP',
        'links'   => ['home', 'stream', 'users']
    ]);
    					

    Models

    Models are used to get and store data in your application. They know nothing about how this data is to be presented in the views. Models extend the Core\Model class and use PDO to access the database. They're stored in the App/Models folder. A sample user model class is included in App/Models/User.php. You can get the PDO database connection instance like this:

    $db = static::getDB();
    					

    Errors

    If the SHOW_ERRORS configuration setting is set to true, full error detail will be shown in the browser if an error or exception occurs. If it's set to false, a generic message will be shown using the App/Views/404.html or App/Views/500.html views, depending on the error.

    5. Updates Back to top

    Each update replace some old files. If you made changes in code and want to update it - you can ask permission to private GitHub repository with all changes. You can ask access here.

    6. 3rd party Components Back to top

    Application uses and include 3rd party components. Here is list:

    To update Twig, PHPMailer or Mailgun you can use:

    composer update
    					

    The rest can be updated manually in public\media\vendors folder.

    Copyright © QxAPHP. All rights reserved.