Link Search Menu Expand Document

Configuration

Table of contents

  1. app.php
    1. const
    2. cache
    3. logs
  2. database.php
    1. Configuration Parameters
  3. encryption.php
  4. routes.php
  5. custom.php
    1. Usage Example

Primary configuration settings are bound to the .env file. For more granular control over your workflow, configuration files are grouped within a single directory. You can view an example of the configuration structure in the official GitHub repository.

app.php

The config/app.php file is used to store read-only variables that can be retrieved within your controllers. This file is structured as a PHP array and consists of three root identifiers: const, cache, and logs.

const

You can register application-wide constants in the const section. For example:

<?php return [
    'const' => [
        'API' => 'https://localhost:3000/api/',
    ]
    // ...
];

cache

By default, the Puko Framework utilizes Memcached as its caching driver. You can configure the connection settings here.

<?php return [
    // ...
    'cache' => [
        'kind' => 'MEMCACHED',
        'expired' => 100,
        'host' => 'localhost',
        'port' => 11211,
    ]
    // ...
];

Note: Advanced cache implementations are coming soon.

logs

Puko utilizes logs as a custom hook with built-in Slack Incoming WebHooks for error reporting (disabled by default). If you have a Slack account, you can set up an Incoming WebHook URL and provide it in the configuration. Set the active state to true to enable Slack notifications.

Note: Support for custom logs is coming soon.

database.php

Database configurations are located in the config/database.php directory. You can specify multiple connections by using unique schema names as identifiers. Puko simplifies the database configuration process via the pukoconsole tool, which is included as a development dependency.

As of version 1.1.6, Puko supports MySQL and MSSQL database engines.

To set up your database, run:

php puko setup db

To refresh the database without overwriting existing configurations, use: php puko refresh db.

Configuration Parameters

ParameterDescriptionExample
Database TypeSupported engines: mysql or mssql.mysql
HostnameThe IP address or hostname of the database server.localhost
PortThe port used by the database server.3306
Schema NameA unique identifier for the connection (e.g., for multiple databases).primary
Database NameThe name of the database.inventory
UsernameThe database user.root
PasswordThe password for the database user.******
DriverThe specific database driver to use.mysql

The setup wizard will ask if you would like to configure additional connections (y/n).

For more detailed information, please refer to the Database section.

encryption.php

Encryption is essential for securing various aspects of your application. The Puko Framework uses encryption primarily to protect user authentication data across Sessions, Cookies, and Bearer tokens. This can be configured using the pukoconsole tool.

Puko utilizes the AES-256-CBC encryption algorithm.

To configure encryption, run the following command in your terminal:

php puko setup secure

routes.php

The config/routes.php file contains all routing information. This file is intended to be read-only, as most routing is managed automatically by the pukoconsole tool.

For more details, see the Routing documentation.

custom.php

Puko allows for the creation of custom configuration files. For example, if you wish to integrate RabbitMQ, you can create a config/rabbitmq.php file:

<?php return [
    'username' => 'administrator',
    'password' => '*******',
    'host' => '192.16.60.31',
    'port' => '5678'
];

Custom configuration files are accessible throughout the application lifecycle via Config::Data('<filename>'). This provides a flexible way to extend the framework’s functionality.

Usage Example

You can retrieve values using the following code snippet:

// Initialize the config data
$config = pukoframework\config\Config::Data('rabbitmq');

// Retrieve values
$username = $config['username'];
$password = $config['password'];
$host     = $config['host'];
$port     = $config['port'];