Skip to content

Commit

Permalink
Merge pull request #7 from Triangle-org/v7
Browse files Browse the repository at this point in the history
Upd
  • Loading branch information
localzet authored Sep 6, 2024
2 parents d04c660 + b19d846 commit 1f91174
Show file tree
Hide file tree
Showing 9 changed files with 325 additions and 0 deletions.
21 changes: 21 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

return [
'debug' => (bool)env('APP_DEBUG', false),
'name' => env('APP_NAME', 'Triangle App'),

'plugin_alias' => env('APP_PLUGIN_ALIAS', 'plugin'),
'plugin_uri' => env('APP_PLUGIN_URI', 'app'),

'controller_suffix' => env('CONTROLLER_SUFFIX', ''),
'controller_reuse' => env('CONTROLLER_REUSE', true),

'headers' => [
'Content-Language' => 'ru',
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Allow-Methods' => '*',
'Access-Control-Allow-Headers' => '*',
'X-Powered-By' => 'Triangle-Core/' . Composer\InstalledVersions::getVersion('triangle/engine'),
],
];
31 changes: 31 additions & 0 deletions config/console.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

$base_path = defined('BASE_PATH') ? BASE_PATH : (Composer\InstalledVersions::getRootPackage()['install_path'] ?? null);

return [
'enable' => true,

'build' => [
// Для PHAR
'input_dir' => $base_path,
'output_dir' => $base_path . DIRECTORY_SEPARATOR . 'build',

'exclude_pattern' => '#^(?!.*(composer.json|/.github/|/.idea/|/.git/|/.setting/|/runtime/|/vendor-bin/|/build/))(.*)$#',
'exclude_files' => [
'.env', 'LICENSE', 'composer.json', 'composer.lock', 'triangle.phar', 'triangle'
],

'phar_alias' => 'triangle',
'phar_filename' => 'triangle.phar',
'phar_stub' => 'master', // Файл для require. Относительный путь, от корня `input_dir`

'signature_algorithm' => Phar::SHA256, // Phar::MD5, Phar::SHA1, Phar::SHA256, Phar::SHA512, Phar::OPENSSL.
'private_key_file' => '', // Для Phar::OPENSSL

// Для бинарной сборки:
'php_version' => 8.3,
'php_ini' => 'memory_limit = 256M',

'bin_filename' => 'triangle',
],
];
79 changes: 79 additions & 0 deletions config/database.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

return [
'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DB_SQLITE_URL', env('DB_URL')),
'prefix' => env('DB_SQLITE_PREFIX', env('DB_PREFIX', '')),
'database' => base_path(env('DB_SQLITE_DATABASE', env('DB_DATABASE', 'resources/database.sqlite'))),
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],

'mysql' => [
'driver' => 'mysql',
'url' => env('DB_MYSQL_URL', env('DB_URL')),
'host' => env('DB_MYSQL_HOST', env('DB_HOST', '127.0.0.1')),
'port' => env('DB_MYSQL_PORT', env('DB_PORT', 3306)),
'prefix' => env('DB_MYSQL_PREFIX', env('DB_PREFIX', '')),
'database' => env('DB_MYSQL_DATABASE', env('DB_DATABASE', 'database')),
'username' => env('DB_MYSQL_USERNAME', env('DB_USERNAME', 'root')),
'password' => env('DB_MYSQL_PASSWORD', env('DB_PASSWORD', '')),
'charset' => env('DB_MYSQL_CHARSET', env('DB_CHARSET', 'utf8mb4')),
'unix_socket' => env('DB_MYSQL_SOCKET', env('DB_SOCKET', '')),
'collation' => 'utf8mb4_unicode_ci',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],

'pgsql' => [
'driver' => 'pgsql',
'url' => env('DB_PGSQL_URL', env('DB_URL')),
'host' => env('DB_PGSQL_HOST', env('DB_HOST', '127.0.0.1')),
'port' => env('DB_PGSQL_PORT', env('DB_PORT', 5432)),
'prefix' => env('DB_PGSQL_PREFIX', env('DB_PREFIX', '')),
'database' => env('DB_PGSQL_DATABASE', env('DB_DATABASE', 'database')),
'username' => env('DB_PGSQL_USERNAME', env('DB_USERNAME', 'root')),
'password' => env('DB_PGSQL_PASSWORD', env('DB_PASSWORD', '')),
'charset' => env('DB_PGSQL_CHARSET', env('DB_CHARSET', 'utf8')),
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => 'prefer',
],

'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DB_SQLSRV_URL', env('DB_URL')),
'host' => env('DB_SQLSRV_HOST', env('DB_HOST', '127.0.0.1')),
'port' => env('DB_SQLSRV_PORT', env('DB_PORT', 1433)),
'prefix' => env('DB_SQLSRV_PREFIX', env('DB_PREFIX', '')),
'database' => env('DB_SQLSRV_DATABASE', env('DB_DATABASE', 'database')),
'username' => env('DB_SQLSRV_USERNAME', env('DB_USERNAME', 'root')),
'password' => env('DB_SQLSRV_PASSWORD', env('DB_PASSWORD', '')),
'charset' => env('DB_SQLSRV_CHARSET', env('DB_CHARSET', 'utf8')),
'encrypt' => env('DB_SQLSRV_ENCRYPT', env('DB_ENCRYPT', 'yes')),
'trust_server_certificate' => env('DB_SQLSRV_TRUST_SERVER_CERTIFICATE', 'false'),
'prefix_indexes' => true,
],

'mongodb' => [
'driver' => 'mongodb',
'url' => env('DB_MONGODB_URL', env('DB_URL')),
'host' => env('DB_MONGODB_HOST', env('DB_HOST', '127.0.0.1')),
'port' => env('DB_MONGODB_PORT', env('DB_PORT', 27017)),
'database' => env('DB_MONGODB_DATABASE', env('DB_DATABASE', 'database')),
'username' => env('DB_MONGODB_USERNAME', env('DB_USERNAME', 'root')),
'password' => env('DB_MONGODB_PASSWORD', env('DB_PASSWORD', '')),
'options' => [
'directConnection' => env('DB_MONGODB_DIRECT_CONNECTION', 'true'),
'authSource' => env('DB_MONGODB_AUTH_SOURCE', 'admin'),
'appname' => env('DB_MONGODB_APP_NAME', env('APP_NAME', 'Triangle App')),
],
],
],
];
27 changes: 27 additions & 0 deletions config/event.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* @package Triangle Events Component
* @link https://github.com/Triangle-org/Events
*
* @author Ivan Zorin <creator@localzet.com>
* @copyright Copyright (c) 2023-2024 Triangle Framework Team
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* For any questions, please contact <triangle@localzet.com>
*/

return [];
33 changes: 33 additions & 0 deletions config/exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* @package Triangle HTTP Component
* @link https://github.com/Triangle-org/Http
*
* @author Ivan Zorin <creator@localzet.com>
* @copyright Copyright (c) 2023-2024 Triangle Framework Team
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* For any questions, please contact <triangle@localzet.com>
*/

use Triangle\Exception\BusinessException;
use Triangle\Exception\ExceptionHandler;

return [
'' => ExceptionHandler::class,
'dont_report' => [BusinessException::class]
];
6 changes: 6 additions & 0 deletions config/middleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
'' => [
]
];
78 changes: 78 additions & 0 deletions config/session.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

/**
* @package Triangle Session Component
* @link https://github.com/Triangle-org/Session
*
* @author Ivan Zorin <creator@localzet.com>
* @copyright Copyright (c) 2023-2024 Triangle Framework Team
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* For any questions, please contact <triangle@localzet.com>
*/

return [
'type' => env('SESSION_TYPE', 'file'),
'handler' => match (env('SESSION_TYPE', 'file')) {
'file' => Triangle\Session\Handlers\FileSessionHandler::class,
'mongo' => Triangle\Session\Handlers\MongoSessionHandler::class,
'redis' => Triangle\Session\Handlers\RedisSessionHandler::class,
'redis_cluster' => Triangle\Session\Handlers\RedisClusterSessionHandler::class,
},
'config' => [
'file' => [
'save_path' => runtime_path('sessions'),
],
'mongo' => [
'host' => env('SESSION_MONGO_HOST', '127.0.0.1'),
'port' => env('SESSION_MONGO_PORT', 27017),
'database' => env('SESSION_MONGO_DATABASE', 'default'),
'username' => env('SESSION_MONGO_USER', 'root'),
'password' => env('SESSION_MONGO_PASS'),
'collection' => env('SESSION_MONGO_COLLECTION', 'sessions'),
'options' => [
'directConnection' => env('MONGO_DIRECT_CONNECTION', 'true'),
'authSource' => env('MONGO_AUTH_SOURCE', 'admin'),
'appname' => env('APP_NAME', 'Triangle App'),
],
],
'redis' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'port' => env('REDIS_PORT', '6379'),
'auth' => env('REDIS_PASSWORD'),
'database' => env('REDIS_DB_SESSION', '2'),
'timeout' => 2,
'prefix' => env('REDIS_PREFIX_SESSION', 'triangle_session_'),
],
'redis_cluster' => [
'host' => ['127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7001'],
'auth' => env('REDIS_PASSWORD'),
'timeout' => 2,
'prefix' => env('REDIS_PREFIX_SESSION', 'triangle_session_'),
]
],

'auto_update_timestamp' => env('SESSION_AUTO_UPDATE', false),
'lifetime' => (int)env('SESSION_LIFETIME', 7 * 24 * 60 * 60),
'session_name' => env('SESSION_COOKIE_NAME', 'PHPSID'),
'cookie_lifetime' => (int)env('SESSION_COOKIE_LIFETIME', 365 * 24 * 60 * 60),
'cookie_path' => env('SESSION_COOKIE_PATH', '/'),
'domain' => env('SESSION_COOKIE_DOMAIN', ''),
'http_only' => env('SESSION_COOKIE_HTTP_ONLY', true),
'secure' => env('SESSION_COOKIE_SECURE', false),
'same_site' => env('SESSION_COOKIE_SAME_SITE', ''),
'gc_probability' => [1, 1000],
];
7 changes: 7 additions & 0 deletions config/static.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'enable' => env('STATIC_ENABLE', true),
'middleware' => [
],
];
43 changes: 43 additions & 0 deletions config/view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* @package Triangle View Component
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin <creator@localzet.com>
* @copyright Copyright (c) 2023-2024 Triangle Framework Team
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* For any questions, please contact <triangle@localzet.com>
*/

use Triangle\View\Render\Blade;
use Triangle\View\Render\Raw;
use Triangle\View\Render\ThinkPHP;
use Triangle\View\Render\Twig;

return [
'handler' => match (env('VIEW_HANDLER', 'raw')) {
'blade' => Blade::class,
'raw' => Raw::class,
'think' => ThinkPHP::class,
'twig' => Twig::class,
},
'options' => [
'view_suffix' => 'phtml',
'vars' => [],
],
];

0 comments on commit 1f91174

Please sign in to comment.