Skip to content

Commit

Permalink
Update app template.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Jan 22, 2024
1 parent f444a25 commit b8c6732
Show file tree
Hide file tree
Showing 54 changed files with 3,204 additions and 569 deletions.
63 changes: 34 additions & 29 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,20 @@
],
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"serve": [
"Composer\\Config::disableProcessTimeout",
"./yii serve"
],
"test": "codecept run",
"test-watch": "phpunit-watcher watch",
"post-install-cmd": [
"App\\Installer::postUpdate",
"App\\Installer::copyEnvFile"
],
"post-update-cmd": [
"App\\Installer::postUpdate",
"App\\Installer::copyEnvFile"
],
"post-create-project-cmd": [
"App\\Installer::copyEnvFile"
]
},
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-intl": "*",
"httpsoft/http-message": "^1.1",
"php-forge/awesome-component": "dev-main",
"php-forge/foxy": "dev-main as 0.1",
"php-forge/html": "dev-main",
"psr/container": "^2.0",
"psr/http-message": "^1.1|^2.0",
"psr/http-server-handler": "^1.0",
"symfony/console": "^6.0",
"vlucas/phpdotenv": "^5.3",
"yiisoft/aliases": "^3.0",
"yii3-extensions/asset-flowbite":"dev-main",
"yii3-extensions/asset-fontawesome-free":"^0.1-dev",
"yiisoft/assets": "^4.0",
"yiisoft/cache": "^3.0",
"yiisoft/cache-file": "^3.0",
Expand All @@ -48,19 +33,19 @@
"yiisoft/error-handler": "^3.0",
"yiisoft/factory": "^1.0",
"yiisoft/files": "^2.0",
"yiisoft/html": "^3.0",
"yiisoft/http": "^1.2",
"yiisoft/i18n": "^1.1",
"yiisoft/log": "^2.0",
"yiisoft/log-target-file": "^3.0",
"yiisoft/router": "^3.0",
"yiisoft/router-fastroute": "^3.0",
"yiisoft/translator": "^3.0",
"yiisoft/translator-extractor": "^2.0",
"yiisoft/translator-message-php": "^1.1",
"yiisoft/view": "^8.0",
"yiisoft/yii-console": "^2.0",
"yiisoft/yii-debug": "dev-master|dev-php80",
"yiisoft/yii-event": "^2.0",
"yiisoft/yii-event": "^2.1",
"yiisoft/yii-http": "^1.0",
"yiisoft/yii-middleware": "^1.0",
"yiisoft/yii-runner-console": "^2.0",
Expand Down Expand Up @@ -95,17 +80,37 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "0.1-dev"
},
"config-plugin-file": "configuration.php"
},
"scripts": {
"serve": [
"Composer\\Config::disableProcessTimeout",
"./yii serve"
],
"test": "codecept run",
"test-watch": "phpunit-watcher watch",
"post-install-cmd": [
"App\\Installer::postUpdate",
"App\\Installer::copyEnvFile"
],
"post-update-cmd": [
"App\\Installer::postUpdate",
"App\\Installer::copyEnvFile"
],
"post-create-project-cmd": [
"App\\Installer::copyEnvFile"
]
},
"config": {
"sort-packages": true,
"allow-plugins": {
"yiisoft/config": true,
"infection/extension-installer": true,
"codeception/c3": true,
"composer/installers": true
}
"composer/installers": true,
"infection/extension-installer": true,
"php-forge/foxy": true,
"yiisoft/config": true
},
"sort-packages": true
}
}
6 changes: 2 additions & 4 deletions config/common/aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
'@assets' => '@root/public/assets',
'@assetsUrl' => '@baseUrl/assets',
'@baseUrl' => '/',
'@messages' => '@resources/messages',
'@messages' => '@resource/messages',
'@npm' => '@root/node_modules',
'@public' => '@root/public',
'@resources' => '@root/resources',
'@resource' => '@root/src/Framework/resource',
'@runtime' => '@root/runtime',
'@vendor' => '@root/vendor',
'@layout' => '@resources/views/layout',
'@views' => '@resources/views',
];
13 changes: 11 additions & 2 deletions config/common/di/application-parameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
declare(strict_types=1);

use App\ApplicationParameters;
use Yiisoft\Aliases\Aliases;
use Yiisoft\Definitions\Reference;
use Yiisoft\Router\UrlGeneratorInterface;
use Yiisoft\Translator\TranslatorInterface;

/** @var array $params */

return [
ApplicationParameters::class => [
'class' => ApplicationParameters::class,
'charset()' => [$params['app']['charset']],
'name()' => [$params['app']['name']],
'__construct()' => [
'aliases' => Reference::to(Aliases::class),
'charset' => $params['app']['charset'],
'name' => $params['app']['name'],
'urlGenerator' => Reference::to(UrlGeneratorInterface::class),
'translator' => Reference::to(TranslatorInterface::class),
],
],
];
35 changes: 24 additions & 11 deletions config/common/params.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

declare(strict_types=1);

use App\ViewInjection\CommonViewInjection;
use App\ViewInjection\LayoutViewInjection;
use App\ViewInjection\TranslatorViewInjection;
use App\ApplicationParameters;
use Yiisoft\Aliases\Aliases;
use Yiisoft\Assets\AssetManager;
use Yiisoft\Csrf\CsrfTokenInterface;
use Yiisoft\Definitions\Reference;
use Yiisoft\Yii\View\CsrfViewInjection;
use Yiisoft\I18n\Locale;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\Session\Flash\FlashInterface;
use Yiisoft\Translator\TranslatorInterface;

return [
'app' => [
'charset' => 'UTF-8',
'locale' => 'en',
'locale' => 'en-US',
'name' => 'My Project',
],

Expand All @@ -23,14 +27,23 @@
'locale' => 'en',
'fallbackLocale' => 'en',
'defaultCategory' => 'app',
'categorySources' => [
Reference::to('translation.app'),
],
],

'yiisoft/yii-view' => [
'injections' => [
Reference::to(CommonViewInjection::class),
Reference::to(CsrfViewInjection::class),
Reference::to(LayoutViewInjection::class),
Reference::to(TranslatorViewInjection::class),
'yiisoft/view' => [
'parameters' => [
'app' => Reference::to(ApplicationParameters::class),
'assetManager' => Reference::to(AssetManager::class),
'csrfToken' => Reference::to(CsrfTokenInterface::class),
'currentRoute' => Reference::to(CurrentRoute::class),
'flash' => Reference::to(FlashInterface::class),
'locale' => Reference::to(Locale::class),
],
],

'yiisoft/yii-view' => [
'layout' => '@resource/layout/main',
],
];
4 changes: 2 additions & 2 deletions config/common/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

use App\Controller\SiteController;
use App\UseCase\Home\HomeAction;
use Yiisoft\Router\Group;
use Yiisoft\Router\Route;

return [
Group::create('/{_language}')
->routes(
Route::get('/')->action([SiteController::class, 'index'])->name('home'),
Route::get('/')->action([HomeAction::class, 'run'])->name('home'),
),
];
4 changes: 2 additions & 2 deletions config/console/commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

declare(strict_types=1);

use App\Command\Hello;
use App\UseCase\Hello\HelloCommand;

return [
'hello' => Hello::class,
'hello' => HelloCommand::class,
];
36 changes: 36 additions & 0 deletions config/console/di/translator-extractor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

use Yiisoft\Aliases\Aliases;
use Yiisoft\Definitions\DynamicReference;
use Yiisoft\Translator\Extractor\ContentParser;
use Yiisoft\Translator\Message\Php\MessageSource;
use Yiisoft\TranslatorExtractor\CategorySource;
use Yiisoft\TranslatorExtractor\Extractor;

/** @var array $params */

return [
Extractor::class => [
'__construct()' => [
[
DynamicReference::to([
'class' => CategorySource::class,
'__construct()' => [
'app',
// Please set the following to use extractor.
// MessageReader and MessageWriter should be set to the SAME MessageSource.
DynamicReference::to(static function (Aliases $aliases) {
return new MessageSource($aliases->get('@messages'));
}),
DynamicReference::to(static function (Aliases $aliases) {
return new MessageSource($aliases->get('@messages'));
}),
],
]),
],
'->t'
],
],
];
2 changes: 1 addition & 1 deletion config/web/di/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

use App\Handler\NotFoundHandler;
use App\Framework\Handler\NotFoundHandler;
use Yiisoft\Definitions\DynamicReference;
use Yiisoft\Definitions\Reference;
use Yiisoft\Injector\Injector;
Expand Down
2 changes: 1 addition & 1 deletion config/web/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

use App\EventHandler\SetLocaleEventHandler;
use App\Framework\EventHandler\SetLocaleEventHandler;
use Yiisoft\Yii\Middleware\Event\SetLocaleEvent;

return [
Expand Down
10 changes: 9 additions & 1 deletion config/web/params.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@
],

'locale' => [
'locales' => ['en' => 'en-US', 'ru' => 'ru-RU', 'de' => 'de-DE'],
'locales' => [
'de' => 'de-DE',
'en' => 'en-US',
'es' => 'es-ES',
'fr' => 'fr-FR',
'pt' => 'pt-BR',
'ru' => 'ru-RU',
'zh' => 'zh-CN',
],
'ignoredRequests' => [
'/debug**',
],
Expand Down
5 changes: 4 additions & 1 deletion configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
'$di',
'web/di/*.php',
],
'di-console' => '$di',
'di-console' => [
'$di',
'console/di/*.php',
],
'events' => [],
'events-web' => [
'$events',
Expand Down
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "yii3-extensions-app",
"version": "0.1.0",
"description": "Yii application template",
"keywords": [
"yii3",
"application",
"template"
],
"author": "Wilmer Arambula <[email protected]>",
"license": "MIT",
"dependencies": {
"flag-icons": "^7.1.0"
}
}
10 changes: 8 additions & 2 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

use Yiisoft\Yii\Runner\Http\HttpApplicationRunner;

require_once dirname(__DIR__) . '/autoload.php';

if (isset($_ENV['YII_ENV'])) {
defined('YII_ENV') or define('YII_ENV', $_ENV['YII_ENV']);
} else {
defined('YII_ENV') or define('YII_ENV', 'prod');
}

if (getenv('YII_C3')) {
$c3 = dirname(__DIR__) . '/c3.php';
if (file_exists($c3)) {
Expand All @@ -27,8 +35,6 @@
$_SERVER['SCRIPT_NAME'] = '/index.php';
}

require_once dirname(__DIR__) . '/autoload.php';

// Run HTTP application runner
$runner = new HttpApplicationRunner(
rootPath: dirname(__DIR__),
Expand Down
Loading

0 comments on commit b8c6732

Please sign in to comment.