artdevue / phalcon-scelet
Scelet of Phalcon.
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Type:project
Requires
- php: >=7.0
- filp/whoops: ^2.1
- vlucas/phpdotenv: ^2.5
Requires (Dev)
- phalcon/zephir: dev-master
- phpunit/phpunit: ^4.8
- predis/predis: ^1.1
- symfony/console: *
This package is auto-updated.
Last update: 2024-11-23 06:31:26 UTC
README
This is a Scelet of Phalcon application written on Phalcon framework for the performance boost. This project created to develop applications in an easy way.
Includes
- ENV
- Multimodality
- Multilanguage
- Translation
- Debug Widget (PDW) (this code was taken as the basis)
Have fun :)
How to install
Using Composer (recommended)
Best way to install Scelet of Phalcon would be Composer, if you didn't install it
Run code in the terminal:
composer create-project artdevue/phalcon-scelet -s dev composer update bower update
Using Git
First you need to clone the project, update vendors:
git clone https://github.com/artdevue/phalcon-scelet.git ./project
cd project
composer update
bower update
Requirements
-
= PHP 7.0.x development resources
-
= Phalcon 3.0.2
Features
After setup you’ll have multimodule apps.
- API RESTful module - responds all JSON-like requests.
- BACKEND and FRONTEND - A multi-module application uses the same document root for more than one module.
ENV
It is often helpful to have different configuration values based on the environment where the application is running. For example, you may wish to use a different cache driver locally than you do on your production server.
The main file for the project is in the project root .env
.
If you need to add a configuration for a different IP of Server, you just need to add the configuration file config_local.php IP and the name of the file that will be used for this IP. For example:
return [ '192.168.100.2' => '.env_local' ];
The system automatically creates a copy of file .env.example
Any variable in your
.env
file can be overridden by external environment variables such as server-level or system-level environment variables.
Environment Variable Types
All variables in your .env
files are parsed as strings, so some reserved values have been created to allow you to return a wider range of types from the env()
function:
If you need to define an environment variable with a value that contains spaces, you may do so by enclosing the value in double quotes.
APP_NAME="My Application"
Retrieving Environment Configuration
All of the variables listed in this file will be loaded into the $_ENV
PHP super-global when your application receives a request. However, you may use the env helper to retrieve values from these variables in your configuration files. In fact, if you review the Phalcon configuration files, you will notice several of the options already using this helper:
'debug' => env('APP_DEBUG', false),
The second value passed to the env function is the "default value". This value will be used if no environment variable exists for the given key.
Installing the module
If you want to install a new module, you need using the terminal run the following command
$ php apps/cli.php modules create modulename
modulename - replace it with the name of the module
For example, after executing the commands below in a terminal
$ php apps/cli.php modules create catalog
In the terminal, we see the report module installation
$ php apps/cli.php modules create catalog Do you really want to install the module catalog? Type 'yes' to continue: yes Thank you, continuing... Reading configuration file... Creating a backup of the configuration file... Record changes in the configuration file... Create directories and files for this new module... Installing the module is complete! Use with pleasure!
After installing new module will be immediately available at http://site.com/catalog
The syntax of this command:
$ php apps/cli.php modules create $nameModule $prefixRouter $hostName
- $nameModule - (String - Required value!) Your module name
- $prefixRouter - (String) If the router prefix different from the module name, then enter here. If If you select - null - then there will be no prefix.
- $hostName - (String) Host Name, if you want to have your module on another host. For example: http://catalog.site.com
Using Multilanguage
- You must activate the "multilang => true" option in the configuration file.
- Parameter "default_lang => 'en'" is assigned the default language (now is en)
- Add an array of used languages in the project to the "languages" parameter of the configuration file
- The default language is displayed in URL address without prefixes. For example:
site.com, site.com/page
- If another language is used, then the prefix should be added at the beginning of the URL address. For example:
site.com/ua, site.com/ua/page
- Active language is called via config: In Controller $this->config->lang_active and in Volt config.lang_active
Using Translation (Source is taken from the official documentation)
All files for translation are located in the directory specified in the configuration file with the parameter: name_lang_folder (default is the folder lang) and in the subfolder of the default language in the configuration file with the parameter: default_lang (default lang en)
The variable name consists of the file names and array keys in the file section.
The example of use in the controller:
$accepted = $this->trans->_("validation.accepted", ['attribute' => 'test']);
or
__("validation.accepted", ['attribute' => 'test'])
The example of use in the template volt:
{{ trans._("validation.accepted", ['attribute': 'test']) }}
Get current active language
$this->config->get('lang_active');
or
{{ config.lang_active }}
Using Debug Widget
You just need to activate debug
in the config file or APP_DEBUG
in the .env file.
If you want the debug bar to be shown only to individual users, simply add the user’s IP configuration file to the debugbar_api
array.
License
The MIT License (MIT). Please see License File for more information.