miny / framework
The Core package of the Miny Framework.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 3 236
Dependents: 5
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- php: >=7
Requires (Dev)
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2022-04-16 03:16:43 UTC
README
Miny is a small PHP framework. It is constantly under development and not recommended for production use. Miny is developed as a microframework but its abilities can be extended by powerful modules.
Miny is licensed under the MIT License.
Requirements
- PHP 7
- Composer
Installation, basic usage
An empty application template is available here
If you wish to use the default logging options, create a writable directory called /logs
.
Environments
There are three separate environments available: development and production. The current environment can be set via the Application class' constructor and determines which configuration files should be used. By default the environment setting also determines if debug-level logging is enabled.
The default environment is the production environment.
Defining the environment to be used
When instantiating the Application class, pass the desired constant as the first argument of the constructor.
$app = new Application(Application::ENV_DEV);
The available constants are:
Application::ENV_DEV
- development environmentApplication::ENV_TEST
- testing environmentApplication::ENV_PROD
- production environment
Configuration
Configuration files are pure PHP files containing an array of configuration options.
Configuration files are located in the /config
directory of the application.
Four different configuration files can be defined:
config.common.php
for all environmentsconfig.dev.php
will be used only for the development environmentconfig.test.php
will be loaded for the test environmentconfig.php
for the production environment
config.common.php
contains the baseline configuration. Setting a value here will act as a default
that can be overridden by the environment-specific configuration files.
Services
Using the Inversion of Control container
Miny comes with a powerful Inversion of Control (IoC) container called Container
. It can be used to
create object instances with their dependencies automatically injected.
Obtaining the Container
The Container instance can be obtained by calling $app->getContainer()
.
Basic usage
Instantiating a class is as easy as calling the get
method and passing the class name.
$instance = $container->get('\\Namespace\\ClassName');
Why is this any good? For the simplest of use cases, this method only generates a lot of overhead.
However when a class has multiple dependencies on other objects not yet instantiated, Container
will take
care of tracking down all the necessary data needed to create the class.
TBD