├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md ├── SECURITY.md └── workflows │ └── build.yml ├── Base ├── Container.php ├── Controller.php ├── Event.php ├── Middleware.php ├── Model.php ├── Module.php ├── PageController.php ├── ReadonlyContainer.php ├── ReadonlyModel.php ├── RollbackInterface.php ├── Scheduler.php └── Task.php ├── Constructor ├── Actions │ ├── ActionInterface.php │ ├── ClearCacheAction.php │ └── UpdateRouteCacheAction.php ├── Attributes │ ├── Accessible.php │ ├── Autowiring │ │ ├── AllowAutowire.php │ │ ├── Config.php │ │ ├── DI.php │ │ └── NoAutowire.php │ ├── AvailableAsParent.php │ ├── Dependency.php │ ├── Disabled.php │ ├── ForTestOnly.php │ ├── Hidden.php │ ├── NotFinal.php │ └── Task │ │ └── Purpose.php ├── Cache │ ├── CacheRoutes.php │ ├── ClassWithDataCreator.php │ ├── ClearRandomFileCache.php │ ├── OnceResult.php │ ├── RouteMark.php │ └── WebCron.php ├── Containers │ ├── BaseContainerFactory.php │ ├── ContainerTrait.php │ ├── CoreContainer.php │ ├── CoreContainerInterface.php │ └── TestContainerInterface.php ├── DI │ └── DependencyInjection.php ├── Data │ ├── DebugAnalytics.php │ ├── DynamicParams.php │ ├── Key.php │ ├── MainLogLevel.php │ ├── RoutesPreview.php │ ├── SystemSettings.php │ ├── UrlManager.php │ └── View.php ├── Exceptions │ ├── Cause │ │ ├── DomainException.php │ │ ├── DynamicStateException.php │ │ ├── InvalidArgumentException.php │ │ ├── ParseException.php │ │ └── UnexpectedValueException.php │ ├── CoreErrorException.php │ ├── CoreException.php │ ├── CoreProcessException.php │ ├── Database │ │ └── DatabaseException.php │ ├── Exit │ │ └── AsyncExitException.php │ ├── File │ │ ├── FileResourceAccessException.php │ │ ├── FileResourceModificationException.php │ │ └── FileSystemException.php │ ├── FrameworkException.php │ ├── Http │ │ ├── Http400BadRequestException.php │ │ ├── Http401UnauthorizedException.php │ │ ├── Http403ForbiddenException.php │ │ ├── Http404NotFoundException.php │ │ ├── Http406NotAcceptableException.php │ │ ├── Http409ConflictException.php │ │ ├── Http410GoneException.php │ │ ├── Http429TooManyRequestsException.php │ │ ├── Http500InternalServerErrorException.php │ │ └── Http503ServiceUnavailableException.php │ ├── HttpException.php │ ├── Log │ │ └── InvalidLogLevelException.php │ ├── Reflection │ │ └── ReflectionProcessException.php │ └── Route │ │ ├── AsyncRouteException.php │ │ └── RouteColoredException.php ├── Models │ └── ModelTrait.php ├── Protected │ └── Csrf.php ├── Script │ └── Hlogin.php └── Templates │ ├── PhpTemplate.php │ ├── Template.php │ ├── TemplateInterface.php │ └── TwigTemplate.php ├── Database ├── DbExcessLog.php ├── PdoManager.php ├── StandardDB.php └── SystemDB.php ├── Helpers ├── Abracadabra.php ├── ArrayHelper.php ├── ArrayWriting.php ├── AttributeHelper.php ├── ClassDataInFile.php ├── DefaultValueHelper.php ├── DirectoryCleaner.php ├── DirectoryHelper.php ├── DirectoryInspector.php ├── HostHelper.php ├── NameConverter.php ├── PhpCommentHelper.php ├── ProtectedFileSaver.php ├── RangeChecker.php ├── ReflectionConstant.php ├── ReflectionMethod.php ├── ResourceViewHelper.php ├── RouteHelper.php ├── StorageLibConfigurator.php ├── StrToList.php ├── StringHelper.php └── TaskHelper.php ├── HlebAsyncBootstrap.php ├── HlebBootstrap.php ├── HlebConsoleBootstrap.php ├── HlebQueueBootstrap.php ├── HttpMethods ├── External │ ├── RequestUri.php │ ├── Response.php │ ├── SpareRequest.php │ └── SystemRequest.php ├── Intelligence │ ├── AsyncConsolidator.php │ └── Cookies │ │ ├── AsyncCookies.php │ │ ├── CookieInterface.php │ │ ├── ParseCookies.php │ │ └── StandardCookies.php └── Specifier │ └── DataType.php ├── Init ├── AddressBar.php ├── Autoloader.php ├── Connectors │ ├── HlebConnector.php │ ├── PhphlebConnector.php │ └── Preload │ │ └── search-functions.php ├── CustomAutoloader.php ├── ErrorLog.php ├── Functions.php ├── Headers │ ├── ParsePsrHeaders.php │ └── ParseSwooleHeaders.php ├── Review │ ├── basic.php │ └── functions.php └── ShootOneselfInTheFoot │ ├── ArrForTest.php │ ├── BaseMockAddOn.php │ ├── CacheForTest.php │ ├── CommandForTest.php │ ├── ContainerForTest.php │ ├── ConverterForTest.php │ ├── CookiesForTest.php │ ├── CsrfForTest.php │ ├── DbForTest.php │ ├── DebugForTest.php │ ├── DiForTest.php │ ├── LogForTest.php │ ├── Mock.php │ ├── OnceForTest.php │ ├── PatchForTest.php │ ├── RedirectForTest.php │ ├── RequestForTest.php │ ├── ResponseForTest.php │ ├── RouterForTest.php │ ├── ScriptForTest.php │ ├── SessionForTest.php │ ├── SettingForTest.php │ ├── SystemForTest.php │ ├── TemplateForTest.php │ └── ViewForTest.php ├── LICENSE ├── Main ├── BaseErrorPage.php ├── Console │ ├── Colorizer.php │ ├── Commands │ │ ├── CliLogLevel.php │ │ ├── ConfigInfo.php │ │ ├── CustomTask.php │ │ ├── Deployer │ │ │ ├── DeploymentLibInterface.php │ │ │ ├── LibDeployerCreator.php │ │ │ ├── LibDeployerFinder.php │ │ │ └── LibraryDeployer.php │ │ ├── Features │ │ │ ├── AutoloaderSupport │ │ │ │ └── AutoloaderSupport.php │ │ │ ├── CodeCleanup │ │ │ │ └── ClearingComments.php │ │ │ ├── CommandDetails │ │ │ │ ├── AllCommands.php │ │ │ │ ├── CommandArgument.php │ │ │ │ └── CustomList.php │ │ │ ├── ExecutionSpeed │ │ │ │ └── ExecutionSpeed.php │ │ │ ├── FeatureInterface.php │ │ │ ├── FlatKegling │ │ │ │ ├── Calculations.php │ │ │ │ ├── ExpressionTrait.php │ │ │ │ ├── FlatKeglingGame.php │ │ │ │ ├── StartData.php │ │ │ │ └── WinStorage.php │ │ │ ├── OriginCommand │ │ │ │ └── OriginCommandReturn.php │ │ │ └── ReverseMode │ │ │ │ ├── ReverseHlCheckMode.php │ │ │ │ └── ReverseStrictMode.php │ │ ├── FindRouteTrait.php │ │ ├── Help │ │ │ └── HelpGenerator.php │ │ ├── LatestLogs.php │ │ ├── LockProject.php │ │ ├── RouteCacheUpdater.php │ │ ├── RouteClearCache.php │ │ ├── RouteInfo.php │ │ ├── RouteList.php │ │ ├── SearchRoute.php │ │ ├── ShortList.php │ │ ├── TemplateCreator.php │ │ └── TwigCacheUpdater.php │ ├── Console.php │ ├── ConsoleAdapter.php │ ├── ConsoleHandler.php │ ├── Extreme │ │ ├── ExtremeDataTransfer.php │ │ ├── ExtremeIdentifier.php │ │ ├── ExtremeRegister.php │ │ ├── ExtremeRequest.php │ │ └── ExtremeTerminal.php │ ├── IndexedArgConverter.php │ ├── ReplacingColorizer.php │ ├── Sections │ │ └── ModuleCreator.php │ ├── Specifiers │ │ ├── ArgType.php │ │ └── LightDataType.php │ ├── WebConsole.php │ └── WebConsoleOnPage.php ├── ErrorTemplates.php ├── Info │ └── PathInfoDoc.php ├── Insert │ ├── BaseAsyncSingleton.php │ ├── BaseSingleton.php │ ├── ContainerUniqueItem.php │ ├── ExternalSingleton.php │ └── OpenInstanceSingleton.php ├── Logger │ ├── BaseLogger.php │ ├── FileLogger.php │ ├── Log.php │ ├── LogCleaner.php │ ├── LogLevel.php │ ├── LoggerAdapter.php │ ├── LoggerInterface.php │ ├── LoggerWrapper.php │ ├── NullLogger.php │ └── StreamLogger.php ├── ProjectLoader.php ├── RouteExtractor.php ├── Routes │ ├── BaseRoute.php │ ├── Methods │ │ ├── BaseType.php │ │ └── Traits │ │ │ ├── Group │ │ │ ├── GroupAfterTrait.php │ │ │ ├── GroupBeforeTrait.php │ │ │ ├── GroupDomainTrait.php │ │ │ ├── GroupMiddlewareTrait.php │ │ │ ├── GroupNoDebugTrait.php │ │ │ ├── GroupPlainTrait.php │ │ │ ├── GroupPrefixTrait.php │ │ │ ├── GroupProtectTrait.php │ │ │ ├── GroupTrait.php │ │ │ ├── GroupWhereTrait.php │ │ │ └── StandardGroupTrait.php │ │ │ ├── InsertAfterTrait.php │ │ │ ├── InsertBeforeTrait.php │ │ │ ├── InsertControllerTrait.php │ │ │ ├── InsertDomainTrait.php │ │ │ ├── InsertMiddlewareTrait.php │ │ │ ├── InsertModuleTrait.php │ │ │ ├── InsertNameTrait.php │ │ │ ├── InsertNoDebugTrait.php │ │ │ ├── InsertPageTrait.php │ │ │ ├── InsertPlainTrait.php │ │ │ ├── InsertProtectTrait.php │ │ │ ├── InsertRedirectTrait.php │ │ │ ├── InsertWhereTrait.php │ │ │ └── StandardTrait.php │ ├── Prepare │ │ ├── Defender.php │ │ ├── FileChecker.php │ │ ├── Handler.php │ │ ├── Optimizer.php │ │ └── Verifier.php │ ├── Route.php │ ├── Search │ │ ├── FindRoute.php │ │ ├── RouteAnyFileManager.php │ │ ├── RouteAsyncFileManager.php │ │ ├── RouteFileManager.php │ │ └── SearchBlock.php │ ├── StandardRoute.php │ └── Update │ │ ├── CheckRouteForUpdates.php │ │ └── RouteData.php ├── System │ ├── LibraryServiceAddress.php │ └── LibraryServiceResources.php └── Workspace.php ├── Optional ├── Modules │ └── example │ │ ├── config │ │ └── main.php │ │ ├── controllers │ │ └── DefaultModuleController.php │ │ └── views │ │ └── example.php └── Templates │ ├── controller_class_template.php │ ├── middleware_class_template.php │ ├── model_class_template.php │ └── task_class_template.php ├── Reference ├── ArrInterface.php ├── ArrReference.php ├── CacheInterface.php ├── CacheReference.php ├── CommandInterface.php ├── CommandReference.php ├── ConverterInterface.php ├── ConverterReference.php ├── CookieInterface.php ├── CookieReference.php ├── CsrfInterface.php ├── CsrfReference.php ├── DbInterface.php ├── DbReference.php ├── DebugInterface.php ├── DebugReference.php ├── DiInterface.php ├── DiReference.php ├── DtoInterface.php ├── DtoReference.php ├── Interface │ ├── Arr.php │ ├── Cache.php │ ├── Command.php │ ├── Converter.php │ ├── Cookie.php │ ├── Csrf.php │ ├── DI.php │ ├── Db.php │ ├── Debug.php │ ├── Dto.php │ ├── Log.php │ ├── Path.php │ ├── Redirect.php │ ├── Request.php │ ├── Response.php │ ├── Router.php │ ├── Session.php │ ├── Setting.php │ ├── System.php │ └── Template.php ├── LogInterface.php ├── LogReference.php ├── OnceInterface.php ├── PathInterface.php ├── PathReference.php ├── RedirectInterface.php ├── RedirectReference.php ├── RequestInterface.php ├── RequestReference.php ├── ResponseInterface.php ├── ResponseReference.php ├── RouterInterface.php ├── RouterReference.php ├── ScriptInterface.php ├── SessionInterface.php ├── SessionReference.php ├── SettingInterface.php ├── SettingReference.php ├── SystemInterface.php ├── SystemReference.php ├── TemplateInterface.php ├── TemplateReference.php └── ViewInterface.php ├── Route ├── After.php ├── Alias.php ├── Any.php ├── Controller.php ├── Delete.php ├── Domain.php ├── Fallback.php ├── Get.php ├── Group │ ├── EndGroup.php │ ├── GroupAfter.php │ ├── GroupDomain.php │ ├── GroupMiddleware.php │ ├── GroupNoDebug.php │ ├── GroupPlain.php │ ├── GroupPrefix.php │ ├── GroupProtect.php │ ├── GroupWhere.php │ └── ToGroup.php ├── MatchTypes.php ├── Middleware.php ├── Module.php ├── Name.php ├── NoDebug.php ├── Options.php ├── Page.php ├── Patch.php ├── Plain.php ├── Post.php ├── Protect.php ├── Put.php ├── Redirect.php └── Where.php ├── Static ├── Arr.php ├── Cache.php ├── Command.php ├── Container.php ├── Converter.php ├── Cookies.php ├── Csrf.php ├── DB.php ├── DI.php ├── Debug.php ├── Log.php ├── Once.php ├── Path.php ├── Redirect.php ├── Request.php ├── Response.php ├── Router.php ├── Script.php ├── Session.php ├── Settings.php ├── System.php ├── Template.php └── View.php ├── bootstrap.php ├── composer.json ├── console.php ├── preload.php ├── readme.md └── web ├── css ├── default-origin.css ├── default.css ├── error-origin.css └── error.css ├── index.php └── svg └── logo.svg /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | #### What steps will reproduce the problem? 3 | 4 | #### What is the expected result? 5 | 6 | #### What do you get instead? 7 | 8 | 9 | #### Additional info 10 | 11 | | Q | A | 12 | |-------------------|---------------| 13 | | Framework version | 2.**?**.**?** | 14 | | PHP version | 8.**?** | 15 | | Operating system | | 16 | 17 | ------ 18 | _Description of the problem found. For security issues contact maintainers privately._ 19 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | | Q | A | 2 | |--------------|-----------------------------------------------------------| 3 | | Is bugfix? | **Yes / No** | 4 | | New feature? | **Yes / No** | 5 | | Breaks BC? | **Yes / No** | 6 | | Fixed issues | comma-separated list of tickets # fixed by the PR, if any | 7 | 8 | ------ 9 | _Description of the changes being made._ 10 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ----- 4 | Please contact the author to let us know about any security issue you find in the [phphleb](https://github.com/phphleb) repository. 5 | DO NOT use the issue tracker or discuss it in the public forum as it will cause more damage than help. 6 | 7 | Please note that as a non-commercial OpenSource project we are not able to pay bounties at the moment. -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: [ master ] 4 | workflow_dispatch: 5 | 6 | name: tests 7 | 8 | jobs: 9 | tests: 10 | name: PHP-${{ matrix.php }}-${{ matrix.os }} 11 | 12 | env: 13 | extensions: json, pdo 14 | tag: hleb2-php${{ matrix.php }}-${{ matrix.os }} 15 | 16 | runs-on: ${{ matrix.os }} 17 | 18 | strategy: 19 | matrix: 20 | os: 21 | - ubuntu-latest 22 | - windows-latest 23 | 24 | php: 25 | - "8.2" 26 | - "8.3" 27 | - "8.4" 28 | 29 | steps: 30 | - name: Install PHP with extensions 31 | uses: shivammathur/setup-php@v2 32 | 33 | with: 34 | php-version: ${{ matrix.php }} 35 | extensions: ${{ env.extensions }} 36 | ini-values: date.timezone='UTC' 37 | coverage: none 38 | tools: composer:v2 39 | 40 | - name: Check PHP 41 | run: php -v 42 | 43 | - name: Install framework 44 | run: composer create-project phphleb/hleb ./${{ env.tag }} 45 | 46 | - name: Framework version 47 | run: php ./${{ env.tag }}/console --version 48 | 49 | - name: Install tests 50 | run: cd ./${{ env.tag }} && composer require phphleb/tests 51 | 52 | - name: Set strict mode 53 | run: php ./${{ env.tag }}/console reverse-strict-mode-feature --set 54 | 55 | - name: Code reduction check 56 | run: php ./${{ env.tag }}/console clearing-comment-feature 57 | 58 | - name: Check autoloader 59 | run: php ./${{ env.tag }}/console autoloader-support-feature 60 | 61 | - name: Run tests 62 | run: php ./${{ env.tag }}/vendor/phphleb/test-o/run ./vendor/phphleb/tests/ 63 | -------------------------------------------------------------------------------- /Base/Container.php: -------------------------------------------------------------------------------- 1 | 4 | */ 5 | 6 | declare(strict_types=1); 7 | 8 | namespace Hleb\Base; 9 | 10 | use Hleb\Constructor\Attributes\AvailableAsParent; 11 | use Hleb\Constructor\Containers\ContainerTrait; 12 | 13 | /** 14 | * The base class for embedding and using containers in classes that inherit from it. 15 | * To inherit readonly classes, use ReadonlyContainer. 16 | * 17 | * Базовый класс для внедрения и использования контейнеров в наследуемых от него классах. 18 | * Для наследования readonly классов используйте ReadonlyContainer. 19 | */ 20 | #[AvailableAsParent] 21 | abstract class Container 22 | { 23 | use ContainerTrait; 24 | } 25 | -------------------------------------------------------------------------------- /Base/Controller.php: -------------------------------------------------------------------------------- 1 | 4 | */ 5 | 6 | declare(strict_types=1); 7 | 8 | namespace Hleb\Base; 9 | 10 | use Hleb\Constructor\Attributes\AvailableAsParent; 11 | 12 | /** 13 | * The base class of the controller, all controllers must inherit from it. 14 | * 15 | * Базовый класс контроллера, все контроллеры должны быть унаследованы от него. 16 | */ 17 | #[AvailableAsParent] 18 | abstract class Controller extends Container 19 | { 20 | public function __construct(#[\SensitiveParameter] array $config = []) 21 | { 22 | // The parent constructor must always be initialized first. 23 | // Сначала всегда должна идти инициализация родительского конструктора. 24 | parent::__construct($config); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Base/Event.php: -------------------------------------------------------------------------------- 1 | 4 | */ 5 | 6 | declare(strict_types=1); 7 | 8 | namespace Hleb\Base; 9 | 10 | use Hleb\Constructor\Attributes\AvailableAsParent; 11 | 12 | /** 13 | * Parent class for events. 14 | * 15 | * Родительский класс для событий. 16 | */ 17 | #[AvailableAsParent] 18 | abstract class Event extends Container 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /Base/Middleware.php: -------------------------------------------------------------------------------- 1 | 4 | */ 5 | 6 | declare(strict_types=1); 7 | 8 | namespace Hleb\Base; 9 | 10 | use Hleb\Constructor\Attributes\AvailableAsParent; 11 | 12 | /** 13 | * The base class of the middleware controller, 14 | * all middleware controllers must be inherited from it. 15 | * 16 | * Базовый класс контроллера-посредника (middleware), 17 | * все контроллеры-посредники должны быть унаследованы от него. 18 | */ 19 | #[AvailableAsParent] 20 | abstract class Middleware extends Container 21 | { 22 | public function __construct(#[\SensitiveParameter] array $config = []) 23 | { 24 | // The parent constructor must always be initialized first. 25 | // Сначала всегда должна идти инициализация родительского конструктора. 26 | parent::__construct($config); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Base/Model.php: -------------------------------------------------------------------------------- 1 | 4 | */ 5 | 6 | declare(strict_types=1); 7 | 8 | namespace Hleb\Base; 9 | 10 | use Hleb\Constructor\Attributes\AvailableAsParent; 11 | use Hleb\Constructor\Models\ModelTrait; 12 | 13 | /** 14 | * The base class of the model, all Models must be inherited from it. 15 | * To inherit readonly classes, use ReadonlyModel. 16 | * 17 | * Базовый класс модели, все Модели должны быть унаследованы от него. 18 | * Для наследования readonly классов используйте ReadonlyModel. 19 | */ 20 | #[AvailableAsParent] 21 | abstract class Model 22 | { 23 | use ModelTrait; 24 | } 25 | -------------------------------------------------------------------------------- /Base/Module.php: -------------------------------------------------------------------------------- 1 | 4 | */ 5 | 6 | declare(strict_types=1); 7 | 8 | namespace Hleb\Base; 9 | 10 | use Hleb\Constructor\Attributes\AvailableAsParent; 11 | 12 | /** 13 | * The base class for the module controller, all module controllers must inherit from it. 14 | * 15 | * Базовый класс для контроллера модуля, все контроллеры модуля должны быть унаследованы от него. 16 | */ 17 | #[AvailableAsParent] 18 | abstract class Module extends Container 19 | { 20 | public function __construct(#[\SensitiveParameter] array $config = []) 21 | { 22 | // The parent constructor must always be initialized first. 23 | // Сначала всегда должна идти инициализация родительского конструктора. 24 | parent::__construct($config); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Base/ReadonlyContainer.php: -------------------------------------------------------------------------------- 1 | 4 | */ 5 | 6 | declare(strict_types=1); 7 | 8 | namespace Hleb\Base; 9 | 10 | use Hleb\Constructor\Attributes\AvailableAsParent; 11 | use Hleb\Constructor\Containers\ContainerTrait; 12 | 13 | /** 14 | * The base readonly class for embedding and using containers in readonly classes that inherit from it. 15 | * To inherit non-readonly classes, use Container. 16 | * 17 | * Базовый readonly класс для внедрения и использования контейнеров в наследуемых от него readonly классах. 18 | * Для наследования не-readonly классов используйте Container. 19 | */ 20 | #[AvailableAsParent] 21 | abstract readonly class ReadonlyContainer 22 | { 23 | use ContainerTrait; 24 | } 25 | -------------------------------------------------------------------------------- /Base/ReadonlyModel.php: -------------------------------------------------------------------------------- 1 | 4 | */ 5 | 6 | declare(strict_types=1); 7 | 8 | namespace Hleb\Base; 9 | 10 | use Hleb\Constructor\Attributes\AvailableAsParent; 11 | use Hleb\Constructor\Models\ModelTrait; 12 | 13 | /** 14 | * The base class of the model, all Models must be inherited from it. 15 | * To inherit non-readonly classes, use Model. 16 | * 17 | * Базовый класс модели, все Модели должны быть унаследованы от него. 18 | * Для наследования не-readonly классов используйте Model. 19 | */ 20 | #[AvailableAsParent] 21 | abstract readonly class ReadonlyModel 22 | { 23 | use ModelTrait; 24 | } 25 | -------------------------------------------------------------------------------- /Constructor/Actions/ActionInterface.php: -------------------------------------------------------------------------------- 1 | clear()) { 23 | throw new CoreProcessException('Failed to clear cache.'); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Constructor/Actions/UpdateRouteCacheAction.php: -------------------------------------------------------------------------------- 1 | dataExtraction()))->save(); 26 | } catch (RouteColoredException $e) { 27 | throw new CoreProcessException($e->getError()); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Constructor/Attributes/Accessible.php: -------------------------------------------------------------------------------- 1 | initException(400, $message); 27 | 28 | parent::__construct($message); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Constructor/Exceptions/Http/Http401UnauthorizedException.php: -------------------------------------------------------------------------------- 1 | initException(401, $message); 33 | 34 | parent::__construct($message); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Constructor/Exceptions/Http/Http403ForbiddenException.php: -------------------------------------------------------------------------------- 1 | initException(403, $message); 31 | 32 | parent::__construct($message); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Constructor/Exceptions/Http/Http404NotFoundException.php: -------------------------------------------------------------------------------- 1 | initException(404, $message); 29 | 30 | parent::__construct($message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Constructor/Exceptions/Http/Http406NotAcceptableException.php: -------------------------------------------------------------------------------- 1 | initException(406, $message); 29 | 30 | parent::__construct($message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Constructor/Exceptions/Http/Http409ConflictException.php: -------------------------------------------------------------------------------- 1 | initException(409, $message); 29 | 30 | parent::__construct($message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Constructor/Exceptions/Http/Http410GoneException.php: -------------------------------------------------------------------------------- 1 | initException(410, $message); 31 | 32 | parent::__construct($message); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Constructor/Exceptions/Http/Http429TooManyRequestsException.php: -------------------------------------------------------------------------------- 1 | initException(429, $message); 29 | 30 | parent::__construct($message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Constructor/Exceptions/Http/Http500InternalServerErrorException.php: -------------------------------------------------------------------------------- 1 | initException(500, $message); 27 | 28 | parent::__construct($message); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Constructor/Exceptions/Http/Http503ServiceUnavailableException.php: -------------------------------------------------------------------------------- 1 | initException(503, $message); 30 | 31 | parent::__construct($message); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Constructor/Exceptions/HttpException.php: -------------------------------------------------------------------------------- 1 | httpCode; 39 | } 40 | 41 | /** @internal */ 42 | public function getMessageContent(): string 43 | { 44 | return $this->messageContent; 45 | } 46 | 47 | /** 48 | * Method for displaying standard error handling by the framework. 49 | * 50 | * Метод для вывода стандартного оформления ошибки фреймворком. 51 | */ 52 | protected function initException(int $httpCode, string $message): void 53 | { 54 | $this->httpCode = $httpCode; 55 | 56 | $this->messageContent = (new BaseErrorPage($httpCode, $message))->insert(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Constructor/Exceptions/Log/InvalidLogLevelException.php: -------------------------------------------------------------------------------- 1 | db() / self::container()->get(DbInterface::class) 21 | */ 22 | final protected static function container(): ContainerInterface 23 | { 24 | return Container::getContainer(); 25 | } 26 | 27 | /** 28 | * Returns the framework settings from the container. 29 | * 30 | * Возвращает настройки фреймворка из контейнера. 31 | */ 32 | final protected static function settings(): SettingInterface 33 | { 34 | return self::container()->get(SettingInterface::class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Constructor/Templates/PhpTemplate.php: -------------------------------------------------------------------------------- 1 | data); 29 | unset($this->data); 30 | if (!\str_ends_with($this->path, '.php')) { 31 | $this->path = "{$this->path}.php"; 32 | } 33 | 34 | require SystemSettings::getRealPath($this->path); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Constructor/Templates/TemplateInterface.php: -------------------------------------------------------------------------------- 1 | getBytesFromString($symbols, $length); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Helpers/DefaultValueHelper.php: -------------------------------------------------------------------------------- 1 | constants = $method->getConstants(); 28 | } 29 | 30 | public function all(): array 31 | { 32 | return $this->constants; 33 | } 34 | 35 | public function get(string $name): mixed 36 | { 37 | return $this->constants[$name] ?? false; 38 | } 39 | 40 | public function has(string $name): bool 41 | { 42 | return \array_key_exists($name, $this->constants); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Helpers/StrToList.php: -------------------------------------------------------------------------------- 1 | 'strval', 'int' => 'intval', 'integer' => 'intval', 'float' => 'floatval', 'double' => 'floatval', 'bool' => 'boolval', 'boolean' => 'boolval' 22 | ]; 23 | 24 | /** 25 | * Converting a comma-separated enum to a list. '1, 2, 3, test' in ['1', '2', '3', 'test']. 26 | * 27 | * Преобразование перечисления через запятую в список. '1, 2, 3, test' в ['1', '2', '3', 'test']. 28 | * 29 | * @param string $value - original value. 30 | * - исходное значение. 31 | * 32 | * @param string $type - type of values in array. 33 | * - тип значений в массиве. 34 | * @return array 35 | */ 36 | public static function convert(string $value, string $type = self::STRING_TYPE): array 37 | { 38 | if ($value === '') { 39 | return []; 40 | } 41 | return \array_map(self::TYPES[$type], \array_map('trim', \explode(',', $value))); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Helpers/StringHelper.php: -------------------------------------------------------------------------------- 1 | $v) { 29 | if (!\array_key_exists($k, $s)) { 30 | $result[] = ['first' => $v, 'pos' => $k, 'error' => 'not in second', 'err' => 1]; 31 | } else if ($v !== $s[$k]) { 32 | $result[] = ['first' => $v, 'second' => $s[$k], 'pos' => $k, 'error' => 'does not match', 'err' => 3]; 33 | } 34 | } 35 | for ($i = \count($f); $i < \count($s); $i++) { 36 | $result[] = ['second' => $s[$i], 'pos' => $i, 'error' => 'not in first', 'err' => 2]; 37 | } 38 | return $result; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /HttpMethods/Intelligence/Cookies/CookieInterface.php: -------------------------------------------------------------------------------- 1 | realpath. 8 | * 9 | * Добавление пути для автозагрузки класса: classname => realpath. 10 | */ 11 | 12 | namespace Hleb\Init\Connectors; 13 | 14 | /** 15 | * @internal 16 | */ 17 | final class PhphlebConnector 18 | { 19 | public static array $map = [ 20 | 'Phphleb\Debugpan\Controllers\AppController' => '/phphleb/debugpan/Controllers/AppController.php', 21 | 'Phphleb\Debugpan\Controllers\ResponseTrait' => '/phphleb/debugpan/Controllers/ResponseTrait.php', 22 | 'Phphleb\Debugpan\Controllers\StateController' => '/phphleb/debugpan/Controllers/StateController.php', 23 | 'Phphleb\Debugpan\InitPanel' => '/phphleb/debugpan/InitPanel.php', 24 | 'Phphleb\Debugpan\Panel\Resources' => '/phphleb/debugpan/Panel/Resources.php', 25 | 'Phphleb\Idnaconv\IdnaConvert' => '/phphleb/idnaconv/IdnaConvert.php', 26 | 'Phphleb\Nicejson\JsonConverter' => '/phphleb/nicejson/JsonConverter.php', 27 | 'Phphleb\TestO\Example\ExampleTest' => '/phphleb/test-o/example/ExampleTest.php', 28 | 'Phphleb\TestO\TestCase' => '/phphleb/test-o/TestCase.php', 29 | 'Phphleb\TestO\Tester' => '/phphleb/test-o/Tester.php', 30 | 'Phphleb\TestO\Tests\ArrayEqualsTest' => '/phphleb/test-o/Tests/ArrayEqualsTest.php', 31 | ]; 32 | 33 | public static function add(array $map): void 34 | { 35 | self::$map = \array_merge($map, self::$map); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Init/Connectors/Preload/search-functions.php: -------------------------------------------------------------------------------- 1 | isFile() && $file->getExtension() === 'php') { 41 | $result[] = $file->getRealPath(); 42 | } 43 | } 44 | return $result; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Init/Headers/ParsePsrHeaders.php: -------------------------------------------------------------------------------- 1 | $i) { 22 | // If the list contains duplicate headers by name. 23 | // Если список содержит дубликаты заголовков по названию. 24 | if ($i && \is_array($i)) { 25 | $headers[$n] = \trim(\implode(',', $i)); 26 | } 27 | } 28 | foreach ($headers as $name => $header) { 29 | if (!\is_array($header)) { 30 | $items = []; 31 | $header = \trim((string)$header); 32 | foreach (\explode(',', $header) as $p) { 33 | $r = \trim($p); 34 | if (!\in_array($r, $items)) { 35 | $items[] = $r; 36 | } 37 | } 38 | $headers[$name] = $items; 39 | } 40 | } 41 | return $headers; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Init/Headers/ParseSwooleHeaders.php: -------------------------------------------------------------------------------- 1 | $header) { 16 | if (is_int($name) && is_string($header)) { 17 | $parts = explode(':', $header); 18 | if (count($parts) > 1) { 19 | $name = array_shift($parts); 20 | $header = explode(',', implode(':', $parts)); 21 | $type = 1; 22 | } else { 23 | throw new \InvalidArgumentException('Failed to parse headers.'); 24 | } 25 | } else if ($type === 1) { 26 | throw new \InvalidArgumentException('Wrong headers format.'); 27 | } 28 | if (is_string($name) && is_string($header)) { 29 | $header = explode(',', $header); 30 | } 31 | $headers[$name] = $header; 32 | } 33 | 34 | return $headers; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Init/ShootOneselfInTheFoot/ArrForTest.php: -------------------------------------------------------------------------------- 1 | $value) { 37 | if ($name === 'error.reporting') { 38 | continue; 39 | } 40 | if (\is_bool($value)) { 41 | $value = $value ? 'true' : 'false'; 42 | } 43 | if (\is_array($value)) { 44 | continue; 45 | } 46 | $list[] = "$name: $value"; 47 | } 48 | 49 | return \implode(PHP_EOL, $list) . PHP_EOL; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Main/Console/Commands/Deployer/LibDeployerFinder.php: -------------------------------------------------------------------------------- 1 | getCommands() as $command) { 23 | $custom[] = $command['name']; 24 | } 25 | return $custom; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Main/Console/Commands/Features/ExecutionSpeed/ExecutionSpeed.php: -------------------------------------------------------------------------------- 1 | 5, 2 => 4, 3 => 6, 4 => 3, 5 => 5, 6 => 7, 7 => 2, 8 => 4, 9 => 6, 10 => 8]; 13 | 14 | protected const POSITION = [1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10]; 15 | 16 | protected const DAMAGE = [ 17 | 'direct' => ['1' => [], '1.5' => [7], '2' => [7, 4], '2.5' => [7, 4], '3' => [4, 7, 8], '3.5' => [4, 2, 8], '4' => [1, 2, 4, 5, 8], '4.5' => [1, 2, 5, 8], '5' => [1, 2, 3, 5, 8, 9], '5.5' => [1, 3, 5, 9], '6' => [3, 6, 9], '6.5' => [3, 6, 9], '7' => [6, 9, 10], '7.5' => [6, 10], '8' => [6, 10], '8.5' => [10], '9' => []], 18 | 19 | 'touch' => [1 => [[3, 6, 5, 9], [2, 5, 4, 8]], 2 => [[5, 9], [4, 7]], 3 => [[6, 10], [5, 8]], 4 => [[8], [7]], 5 => [[9], [8]], 6 => [[10], [9]], 7 => [[], []], 8 => [[], []], 9 => [[], []], 10 => [[], []]] 20 | ]; 21 | } 22 | -------------------------------------------------------------------------------- /Main/Console/Commands/Features/OriginCommand/OriginCommandReturn.php: -------------------------------------------------------------------------------- 1 | one($method, $domain ?: ''); 24 | if ($handler->isBlocked()) { 25 | return 'Routes are blocked.' . PHP_EOL; 26 | } 27 | $errors = $handler->getError(); 28 | if ($errors) { 29 | return 'Error! ' . \reset($errors) . PHP_EOL; 30 | } 31 | if (\is_array($search)) { 32 | $search['name'] = $handler->getRouteName(); 33 | $search['params'] = $handler->getData(); 34 | } 35 | 36 | return $search; 37 | } 38 | 39 | protected function splitUrl(string $url, ?string $domain): array 40 | { 41 | $parse = \parse_url($url); 42 | $path = $parse['path'] ?? '/'; 43 | $domain = $parse['host'] ?? $domain; 44 | 45 | return [$path, $domain]; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Main/Console/Commands/LatestLogs.php: -------------------------------------------------------------------------------- 1 | code; 25 | } 26 | 27 | /** 28 | * Updates the route cache. 29 | * 30 | * Обновляет кеш маршрутов. 31 | */ 32 | public function run(): string 33 | { 34 | try { 35 | try { 36 | (new UpdateRouteCacheAction())->run(); 37 | } catch (CoreException) { 38 | $this->code = 1; 39 | return 'Error! Failed to save route cache. Check the necessary permissions.' . PHP_EOL; 40 | } 41 | } catch (\Throwable $e) { 42 | $this->code = 1; 43 | return $e->getMessage() . PHP_EOL; 44 | } 45 | // Если расширение установлено для CLI 46 | if (\function_exists('opcache_reset')) { 47 | \opcache_reset(); 48 | } 49 | $this->code = 0; 50 | return 'The route cache has been successfully updated!' . PHP_EOL; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Main/Console/Commands/RouteClearCache.php: -------------------------------------------------------------------------------- 1 | code; 25 | } 26 | 27 | /** 28 | * Deletes the route cache. 29 | * 30 | * Удаляет кеш маршрутов. 31 | */ 32 | public function run(): string 33 | { 34 | try { 35 | $cleaner = new DirectoryCleaner(); 36 | $cleaner->forceRemoveDir(Path::get('@storage/cache/routes')); 37 | if ($cleaner->getErrors()) { 38 | $this->code = 1; 39 | return 'ERROR:' . implode(PHP_EOL, $cleaner->getErrors()) . PHP_EOL; 40 | } 41 | } catch (\Throwable $e) { 42 | $this->code = 1; 43 | return $e->getMessage() . PHP_EOL; 44 | } 45 | // Если расширение установлено для CLI 46 | if (\function_exists('opcache_reset')) { 47 | \opcache_reset(); 48 | } 49 | $this->code = 0; 50 | return 'The route cache has been successfully cleared!' . PHP_EOL; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Main/Console/Commands/SearchRoute.php: -------------------------------------------------------------------------------- 1 | code; 27 | } 28 | 29 | /** 30 | * Returns a message about the route address that matches the conditions. 31 | * 32 | * Возвращает сообщение об адресе маршрута, который соответствует условиям. 33 | */ 34 | public function run(null|string $url, null|string $httpMethod, null|string $domain): string 35 | { 36 | if ($url === null) { 37 | return 'Error! Required argument `url` not specified: php console --find-route [method] [domain]' . PHP_EOL; 38 | } 39 | 40 | [$url, $domain] = $this->splitUrl($url, $domain); 41 | 42 | $block = $this->getBlock($url, $httpMethod, $domain); 43 | if (\is_string($block)) { 44 | $this->code = 1; 45 | return $block; 46 | } 47 | 48 | return ($block ? 'OK' : 'Not found.') . PHP_EOL; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Main/Console/Commands/TwigCacheUpdater.php: -------------------------------------------------------------------------------- 1 | code; 25 | } 26 | 27 | /** 28 | * Clears the cache for the Twig templating engine. 29 | * 30 | * Очищает кеш для шаблонизатора Twig. 31 | */ 32 | public function run(): string 33 | { 34 | $cleaner = new DirectoryCleaner(); 35 | $cleaner->forceRemoveDir(SystemSettings::getRealPath('storage') . '/cache/twig/compilation'); 36 | $errors = $cleaner->getErrors(); 37 | if ($errors) { 38 | $this->code = 1; 39 | return \end($errors) . PHP_EOL; 40 | } 41 | 42 | return 'Successfully cleared the Twig templating cache.' . PHP_EOL; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Main/Console/Extreme/ExtremeRegister.php: -------------------------------------------------------------------------------- 1 | Web Console
27 |

A login key has been created in the project file: /" . $keyPath . '

'; 28 | $m .= " 29 |
30 | Login key: 31 |
"; 32 | echo $m; 33 | 34 | return false; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Main/Console/Extreme/ExtremeRequest.php: -------------------------------------------------------------------------------- 1 | $uri]); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Main/Console/WebConsoleOnPage.php: -------------------------------------------------------------------------------- 1 | run(); 31 | * 32 | * 33 | * @throws CoreException 34 | */ 35 | public function run(): void 36 | { 37 | Response::addHeaders(['Content-Type' => 'text/html; charset=utf-8']); 38 | ob_start(); 39 | $console = ''; 40 | $result = $this->load(); 41 | $arguments = $this->getArgs(); 42 | $arguments[] = '--strict-verbosity'; 43 | $result and $console = (new ConsoleHandler($arguments))->run(); 44 | $content = ob_get_clean(); 45 | Response::addToBody($content . $this->addFooter($console)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Main/ErrorTemplates.php: -------------------------------------------------------------------------------- 1 | template) { 27 | '404', 404 => new Http404NotFoundException(), 28 | '403', 403 => new Http403ForbiddenException(), 29 | '401', 401 => new Http401UnauthorizedException(), 30 | default => null, 31 | }; 32 | if ($error) { 33 | throw $error; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Main/Insert/BaseAsyncSingleton.php: -------------------------------------------------------------------------------- 1 | toArray(); 23 | } else if ($view !== null) { 24 | $params = (string)$view; 25 | } 26 | $types = \array_unique(\array_map('strtoupper', $this->types())); 27 | 28 | $route = $this->updateRouteAddress($route); 29 | 30 | $default = $this->getDefaultValues($route); 31 | 32 | $data = [ 33 | 'route' => $route, 34 | 'view' => $params, 35 | ]; 36 | 37 | if ($default) { 38 | $data['default'] = $default; 39 | } 40 | 41 | $this->register([ 42 | 'method' => self::ADD_TYPE, 43 | 'name' => $this->methodName(), 44 | 'types' => $types, 45 | 'data' => $data, 46 | ]); 47 | } 48 | 49 | abstract protected function types(): array; 50 | 51 | abstract protected function methodName(): string; 52 | } 53 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/Group/GroupAfterTrait.php: -------------------------------------------------------------------------------- 1 | after(DefaultMiddlewareAfter::class); 31 | * // ... // 32 | * Route::endGroup(); 33 | * ``` 34 | */ 35 | public function after(string $target, ?string $method = null, array $data = []): GroupAfter 36 | { 37 | return new GroupAfter($target, $method, $data); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/Group/GroupBeforeTrait.php: -------------------------------------------------------------------------------- 1 | before(DefaultMiddleware::class); 31 | * // ... // 32 | * Route::endGroup(); 33 | * ``` 34 | */ 35 | public function before(string $target, ?string $method = null, array $data = []): GroupMiddleware 36 | { 37 | return new GroupMiddleware($target, $method, $data); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/Group/GroupMiddlewareTrait.php: -------------------------------------------------------------------------------- 1 | middleware(DefaultMiddleware::class); 29 | * // ... // 30 | * Route::endGroup(); 31 | * ``` 32 | */ 33 | public function middleware(string $target, ?string $method = null, array $data = []): GroupMiddleware 34 | { 35 | return new GroupMiddleware($target, $method, $data); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/Group/GroupNoDebugTrait.php: -------------------------------------------------------------------------------- 1 | noDebug(); 26 | * // ... // 27 | * Route::endGroup(); 28 | * ``` 29 | */ 30 | public function noDebug(): GroupNoDebug 31 | { 32 | return new GroupNoDebug(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/Group/GroupPlainTrait.php: -------------------------------------------------------------------------------- 1 | plain(); 31 | * // ... // 32 | * Route::endGroup(); 33 | *``` 34 | * 35 | * @param bool $on - simplification mode active. 36 | * 37 | * - активность режима упрощения. 38 | */ 39 | public function plain(bool $on = true): GroupPlain 40 | { 41 | return new GroupPlain($on); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/Group/GroupPrefixTrait.php: -------------------------------------------------------------------------------- 1 | prefix('/test/'); 23 | * // ... // 24 | * Route::endGroup(); 25 | * ``` 26 | */ 27 | public function prefix(string $prefix): GroupPrefix 28 | { 29 | return new GroupPrefix($prefix); 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/Group/GroupProtectTrait.php: -------------------------------------------------------------------------------- 1 | protect(); 19 | * // ... // 20 | * Route::endGroup(); 21 | * ``` 22 | */ 23 | public function protect(string|array $rules = 'CSRF'): GroupProtect 24 | { 25 | return new GroupProtect($rules); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/Group/GroupTrait.php: -------------------------------------------------------------------------------- 1 | prefix('example') 20 | * ->group(function () { 21 | * Route::get('/first/', '1st'); 22 | * Route::get('/second/', '2nd'); 23 | * }); 24 | * 25 | * ``` 26 | */ 27 | public function group(callable $fn): EndGroup 28 | { 29 | $fn(); 30 | 31 | return new EndGroup(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/Group/GroupWhereTrait.php: -------------------------------------------------------------------------------- 1 | prefix('/order/{id}')->where(['id' => '[0-9]+']); 20 | * // ... // 21 | * Route::endGroup(); 22 | * ``` 23 | */ 24 | public function where(array $rules): GroupWhere 25 | { 26 | return new GroupWhere($rules); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/Group/StandardGroupTrait.php: -------------------------------------------------------------------------------- 1 | after(After::class); 31 | * ``` 32 | */ 33 | public function after(string $target, ?string $method = null, array $data = []): After 34 | { 35 | return new After($target, $method, $data); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/InsertBeforeTrait.php: -------------------------------------------------------------------------------- 1 | before(Before::class); 31 | * ``` 32 | */ 33 | public function before(string $target, ?string $method = null, array $data = []): Middleware 34 | { 35 | return new Middleware($target, $method, $data); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/InsertControllerTrait.php: -------------------------------------------------------------------------------- 1 | controller(UserController::class); 29 | * ``` 30 | */ 31 | public function controller(string $target, ?string $method = null): Controller 32 | { 33 | return new Controller($target, $method); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/InsertMiddlewareTrait.php: -------------------------------------------------------------------------------- 1 | middleware(DefaultMiddleware::class); 29 | * ``` 30 | */ 31 | public function middleware(string $target, ?string $method = null, array $data = []): Middleware 32 | { 33 | return new Middleware($target, $method, $data); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/InsertNameTrait.php: -------------------------------------------------------------------------------- 1 | name('homepage'); 19 | * ``` 20 | */ 21 | public function name(string $name): Name 22 | { 23 | return new Name($name); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/InsertNoDebugTrait.php: -------------------------------------------------------------------------------- 1 | noDebug(); 25 | * ``` 26 | */ 27 | public function noDebug(): NoDebug 28 | { 29 | return new NoDebug(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/InsertPageTrait.php: -------------------------------------------------------------------------------- 1 | plain(); 31 | * ``` 32 | * 33 | * @param bool $on - simplification mode active. 34 | * 35 | * - активность режима упрощения. 36 | */ 37 | public function plain(bool $on = true): Plain 38 | { 39 | return new Plain($on); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/InsertProtectTrait.php: -------------------------------------------------------------------------------- 1 | controller(UserController::class, 'add') 20 | * ->protect(); 21 | * `` 22 | */ 23 | public function protect(string|array $rules = 'CSRF'): Protect 24 | { 25 | return new Protect($rules); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/InsertRedirectTrait.php: -------------------------------------------------------------------------------- 1 | redirect('/new/address/{%name%}', 301); 28 | * ``` 29 | */ 30 | public function redirect(string $location, int $status = 302): Redirect 31 | { 32 | return new Redirect($location, $status); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/InsertWhereTrait.php: -------------------------------------------------------------------------------- 1 | where(['version' => '[a-z0-9]+', 'page' => '[a-z]+']); 22 | * ``` 23 | */ 24 | public function where(array $rules): Where 25 | { 26 | return new Where($rules); 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Main/Routes/Methods/Traits/StandardTrait.php: -------------------------------------------------------------------------------- 1 | init(); 19 | 20 | if (self::$stubData) { 21 | $this->isBlocked = true; 22 | return \is_array(self::$stubData) ? self::$stubData : false; 23 | } 24 | return parent::searchBlock(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Main/System/LibraryServiceAddress.php: -------------------------------------------------------------------------------- 1 | getUri(); 22 | return $uri->getScheme() . '://' . $uri->getHost() . self::getAddress($library, $version); 23 | } 24 | 25 | /** 26 | * Returns the path to the library resource. 27 | * 28 | * Возвращает путь до ресурса библиотеки. 29 | */ 30 | public static function getAddress(string $library, string $version = 'v1'): string 31 | { 32 | return '/' . self::KEY . '/' . $library . '/' . $version; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Optional/Modules/example/config/main.php: -------------------------------------------------------------------------------- 1 | module('module_base_name_template', DefaultModuleController::class); 19 | * ``` 20 | */ 21 | class DefaultModuleController extends Module 22 | { 23 | public function index(): View 24 | { 25 | /* 26 | * An example of using the template 27 | * (to be included from the /views/ folder of the current module). 28 | * 29 | * Пример использования шаблона 30 | * (будет загружен из папки /views/ текущего модуля). 31 | */ 32 | return view("example"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Optional/Modules/example/views/example.php: -------------------------------------------------------------------------------- 1 | `{$container->settings()->getModuleName()}` template."; 5 | -------------------------------------------------------------------------------- /Optional/Templates/controller_class_template.php: -------------------------------------------------------------------------------- 1 | call($arguments); 26 | 27 | return $task->getExecResult(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Reference/ConverterInterface.php: -------------------------------------------------------------------------------- 1 | token() . '">'; 31 | } 32 | 33 | /** 34 | * @inheritDoc 35 | */ 36 | #[\Override] 37 | public function validate(?string $key): bool 38 | { 39 | return \Hleb\Constructor\Protected\Csrf::validate($key); 40 | } 41 | 42 | /** 43 | * @inheritDoc 44 | */ 45 | #[\Override] 46 | public function discover(): string|null 47 | { 48 | return \Hleb\Constructor\Protected\Csrf::discover(); 49 | } 50 | 51 | /** 52 | * @inheritDoc 53 | */ 54 | #[\Override] 55 | public static function rollback(): void 56 | { 57 | \Hleb\Constructor\Protected\Csrf::rollback(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Reference/DebugInterface.php: -------------------------------------------------------------------------------- 1 | rollback(); 21 | } 22 | 23 | /** @inheritDoc */ 24 | #[\Override] 25 | public function get($name) 26 | { 27 | return self::$data[$name] ?? null; 28 | } 29 | 30 | /** @inheritDoc */ 31 | #[\Override] 32 | public function set($name, #[\SensitiveParameter] $value): void 33 | { 34 | self::$data[$name] = $value; 35 | } 36 | 37 | /** @inheritDoc */ 38 | #[\Override] 39 | public function clear(): void 40 | { 41 | $this->rollback(); 42 | } 43 | 44 | /** @inheritDoc */ 45 | #[\Override] 46 | public function list(): array 47 | { 48 | return self::$data; 49 | } 50 | 51 | /** @inheritDoc */ 52 | #[\Override] 53 | public static function rollback(): void 54 | { 55 | self::$data = []; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Reference/Interface/Arr.php: -------------------------------------------------------------------------------- 1 | $location])); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Reference/ScriptInterface.php: -------------------------------------------------------------------------------- 1 | searchMiddlewareAttributes($target, $method); 34 | 35 | $this->register([ 36 | 'method' => self::AFTER_TYPE, 37 | 'class' => $class, 38 | 'class-method' => $method, 39 | 'from-group' => false, 40 | 'related-data' => $data, 41 | ]); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Route/Alias.php: -------------------------------------------------------------------------------- 1 | register([ 18 | 'method' => self::ALIAS_SUBTYPE, 19 | 'name' => $name, 20 | 'new-name' => $newName, 21 | 'types' => $this->types(), 22 | 'data' => [ 23 | 'route' => $route, 24 | ] 25 | ]); 26 | } 27 | 28 | protected function types(): array 29 | { 30 | return HlebBootstrap::HTTP_TYPES; 31 | } 32 | 33 | protected function methodName(): string 34 | { 35 | return self::ALIAS_SUBTYPE; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Route/Any.php: -------------------------------------------------------------------------------- 1 | getControllerAttributes($target, $method); 34 | 35 | $this->register([ 36 | 'method' => self::CONTROLLER_TYPE, 37 | 'class' => $class, 38 | 'class-method' => $method, 39 | ]); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Route/Delete.php: -------------------------------------------------------------------------------- 1 | register([ 42 | 'method' => self::DOMAIN_TYPE, 43 | 'name' => \is_array($part) ? $part : [$part], 44 | 'level' => $level 45 | ]); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Route/Get.php: -------------------------------------------------------------------------------- 1 | register([ 17 | 'method' => self::END_GROUP_TYPE, 18 | ]); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Route/Group/GroupAfter.php: -------------------------------------------------------------------------------- 1 | searchMiddlewareAttributes($target, $method); 24 | 25 | $this->register([ 26 | 'method' => self::AFTER_TYPE, 27 | 'class' => $class, 28 | 'class-method' => $method, 29 | 'from-group' => true, 30 | 'related-data' => $data, 31 | ]); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Route/Group/GroupDomain.php: -------------------------------------------------------------------------------- 1 | register([ 24 | 'method' => self::DOMAIN_TYPE, 25 | 'name' => \is_array($part) ? $part : [$part], 26 | 'level' => $level, 27 | 'from-group' => true 28 | ]); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Route/Group/GroupMiddleware.php: -------------------------------------------------------------------------------- 1 | searchMiddlewareAttributes($target, $method); 24 | 25 | $this->register([ 26 | 'method' => self::MIDDLEWARE_TYPE, 27 | 'class' => $class, 28 | 'class-method' => $method, 29 | 'from-group' => true, 30 | 'related-data' => $data, 31 | ]); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Route/Group/GroupNoDebug.php: -------------------------------------------------------------------------------- 1 | register([ 20 | 'method' => self::NO_DEBUG_TYPE, 21 | 'from-group' => true, 22 | ]); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Route/Group/GroupPlain.php: -------------------------------------------------------------------------------- 1 | register([ 20 | 'method' => self::PLAIN_TYPE, 21 | 'from-group' => true, 22 | 'data' => ['on' => $on], 23 | ]); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Route/Group/GroupPrefix.php: -------------------------------------------------------------------------------- 1 | register([ 24 | 'method' => self::PREFIX_TYPE, 25 | 'prefix' => $prefix, 26 | 'from-group' => true 27 | ]); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Route/Group/GroupProtect.php: -------------------------------------------------------------------------------- 1 | register([ 22 | 'method' => self::PROTECT_TYPE, 23 | 'from-group' => true, 24 | 'data' => ['rules' => $rules], 25 | ]); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Route/Group/GroupWhere.php: -------------------------------------------------------------------------------- 1 | register([ 24 | 'method' => self::WHERE_TYPE, 25 | 'data' => [ 26 | 'rules' => $rules, 27 | ], 28 | 'from-group' => true 29 | ]); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Route/Group/ToGroup.php: -------------------------------------------------------------------------------- 1 | register([ 24 | 'method' => self::TO_GROUP_TYPE, 25 | ]); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Route/MatchTypes.php: -------------------------------------------------------------------------------- 1 | types, ['OPTIONS'])); 27 | } 28 | 29 | #[\Override] 30 | protected function methodName(): string 31 | { 32 | return self::MATCH_SUBTYPE; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Route/Middleware.php: -------------------------------------------------------------------------------- 1 | searchMiddlewareAttributes($target, $method); 34 | 35 | $this->register([ 36 | 'method' => self::MIDDLEWARE_TYPE, 37 | 'class' => $class, 38 | 'class-method' => $method, 39 | 'from-group' => false, 40 | 'related-data' => $data, 41 | ]); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Route/Module.php: -------------------------------------------------------------------------------- 1 | searchModuleAttributes($name, $target, $method); 34 | 35 | $this->register([ 36 | 'method' => self::MODULE_TYPE, 37 | 'name' => $name, 38 | 'class' => $class, 39 | 'class-method' => $method, 40 | ]); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Route/Name.php: -------------------------------------------------------------------------------- 1 | register([ 40 | 'method' => self::NAME_TYPE, 41 | 'name' => $name 42 | ]); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Route/NoDebug.php: -------------------------------------------------------------------------------- 1 | register([ 40 | 'method' => self::NO_DEBUG_TYPE, 41 | 'from-group' => false, 42 | ]); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Route/Options.php: -------------------------------------------------------------------------------- 1 | getControllerAttributes($target, $method); 34 | 35 | $this->register([ 36 | 'method' => self::PAGE_TYPE, 37 | 'name' => $type, 38 | 'class' => $class, 39 | 'class-method' => $method, 40 | ]); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Route/Patch.php: -------------------------------------------------------------------------------- 1 | register([ 38 | 'method' => self::PLAIN_TYPE, 39 | 'from-group' => false, 40 | 'data' => ['on' => $on], 41 | ]); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Route/Post.php: -------------------------------------------------------------------------------- 1 | register([ 40 | 'method' => self::PROTECT_TYPE, 41 | 'from-group' => false, 42 | 'data' => ['rules' => $rules], 43 | ]); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Route/Put.php: -------------------------------------------------------------------------------- 1 | register([ 32 | 'method' => self::REDIRECT_TYPE, 33 | 'location' => $location, 34 | 'status' => $status, 35 | ]); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Route/Where.php: -------------------------------------------------------------------------------- 1 | register([ 40 | 'method' => self::WHERE_TYPE, 41 | 'data' => [ 42 | 'rules' => $rules, 43 | ] 44 | ]); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Static/Command.php: -------------------------------------------------------------------------------- 1 | execute($task, $arguments); 29 | } 30 | 31 | return BaseContainer::instance()->get(CommandInterface::class)->execute($task, $arguments); 32 | } 33 | 34 | /** 35 | * @internal 36 | * 37 | * @see CommandForTest 38 | */ 39 | #[ForTestOnly] 40 | public static function replaceWithMock(CommandInterface|null $mock): void 41 | { 42 | if (\defined('HLEB_CONTAINER_MOCK_ON') && !HLEB_CONTAINER_MOCK_ON) { 43 | throw new CoreProcessException('The action is prohibited in the settings.'); 44 | } 45 | self::$replace = $mock; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Static/Redirect.php: -------------------------------------------------------------------------------- 1 | to($location, $status); 34 | } else { 35 | BaseContainer::instance()->get(RedirectInterface::class)->to($location, $status); 36 | } 37 | } 38 | 39 | /** 40 | * @internal 41 | * 42 | * @see RedirectForTest 43 | */ 44 | #[ForTestOnly] 45 | public static function replaceWithMock(RedirectInterface|null $mock): void 46 | { 47 | if (\defined('HLEB_CONTAINER_MOCK_ON') && !HLEB_CONTAINER_MOCK_ON) { 48 | throw new CoreProcessException('The action is prohibited in the settings.'); 49 | } 50 | self::$replace = $mock; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /bootstrap.php: -------------------------------------------------------------------------------- 1 | 4 | */ 5 | 6 | declare(strict_types=1); 7 | 8 | use Hleb\HlebBootstrap; 9 | 10 | PHP_VERSION_ID < 80200 and exit('Current PHP version is ' . PHP_VERSION . ', required >= 8.2'); 11 | 12 | \class_exists(HlebBootstrap::class) or require __DIR__ . '/HlebBootstrap.php'; 13 | 14 | (new HlebBootstrap(HLEB_PUBLIC_DIR))->load(); 15 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "phphleb/framework", 3 | "description": "Engine for Framework HLEB2", 4 | "type": "library", 5 | "homepage": "https://hleb2framework.ru", 6 | "keywords": [ 7 | "hleb2", 8 | "phphleb", 9 | "framework", 10 | "php framework", 11 | "php" 12 | ], 13 | "license": "MIT", 14 | "authors": [ 15 | { 16 | "name": "Foma Tuturov", 17 | "email": "fomiash@yandex.ru" 18 | } 19 | ], 20 | "autoload": { 21 | "psr-4": { 22 | "Hleb\\": "/" 23 | } 24 | }, 25 | "require": { 26 | "php": ">=8.2.0", 27 | "phphleb/debugpan": "^2.0.0", 28 | "phphleb/nicejson": "*", 29 | "phphleb/salt": "*" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /console.php: -------------------------------------------------------------------------------- 1 | 4 | */ 5 | 6 | declare(strict_types=1); 7 | 8 | use Hleb\HlebBootstrap; 9 | use Hleb\HlebConsoleBootstrap; 10 | 11 | PHP_VERSION_ID < 80200 and exit('Current PHP version is ' . PHP_VERSION . ', required >= 8.2' . PHP_EOL); 12 | 13 | HLEB_PUBLIC_DIR or exit('Error! The public directory in the \'/console\' file is incorrectly specified.'); 14 | 15 | \class_exists(HlebBootstrap::class) or require __DIR__ . '/HlebBootstrap.php'; 16 | \class_exists(HlebConsoleBootstrap::class) or require __DIR__ . '/HlebConsoleBootstrap.php'; 17 | 18 | exit((new HlebConsoleBootstrap(HLEB_PUBLIC_DIR))->load()); 19 | -------------------------------------------------------------------------------- /preload.php: -------------------------------------------------------------------------------- 1 | getUri()->getPath(), '/')); 19 | $name = \end($address); 20 | 21 | if (\in_array($name, ['error', 'default'])) { 22 | $file = SystemSettings::getRealPath('@library/framework/web/css/' . $name . '.css'); 23 | 24 | if (!$file) { 25 | return false; 26 | } 27 | Response::addHeaders([ 28 | 'Content-Type' => 'text/css; charset=UTF-8', 29 | ]); 30 | } else if ($name === 'logo') { 31 | $file = SystemSettings::getRealPath('@library/framework/web/svg/' . $name . '.svg'); 32 | 33 | if (!$file) { 34 | return false; 35 | } 36 | Response::addHeaders([ 37 | 'Content-Type' => 'image/svg+xml; charset=UTF-8', 38 | ]); 39 | } else { 40 | return false; 41 | } 42 | Response::addHeaders([ 43 | 'Cache-Control' => 'public, max-age=31536000', 44 | 'Pragma' => 'cache' 45 | ]); 46 | isset($file) and Response::setBody(\file_get_contents($file)); 47 | 48 | return true; 49 | --------------------------------------------------------------------------------