Passed
Push — 0.7.0 ( ba8797...2cebcc )
by Alexander
03:45 queued 11s
created

Application::environmentPath()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php 
2
3
/**
4
 * Lenevor Framework
5
 *
6
 * LICENSE
7
 *
8
 * This source file is subject to the new BSD license that is bundled
9
 * with this package in the file license.md.
10
 * It is also available through the world-wide-web at this URL:
11
 * https://lenevor.com/license
12
 * If you did not receive a copy of the license and are unable to
13
 * obtain it through the world-wide-web, please send an email
14
 * to [email protected] so we can send you a copy immediately.
15
 *
16
 * @package     Lenevor
17
 * @subpackage  Base
18
 * @link        https://lenevor.com
19
 * @copyright   Copyright (c) 2019 - 2021 Alexander Campo <[email protected]>
20
 * @license     https://opensource.org/licenses/BSD-3-Clause New BSD license or see https://lenevor.com/license or see /license.md
21
 */
22
23
namespace Syscodes\Core;
24
25
use Closure;
26
use Syscodes\Support\Str;
27
use Syscodes\Collections\Arr;
28
use Syscodes\Container\Container;
29
use Syscodes\Support\Environment;
30
use Syscodes\Support\ServiceProvider;
31
use Syscodes\Log\LoggerServiceProvider;
32
use Syscodes\Events\EventServiceProvider;
33
use Syscodes\Routing\RoutingServiceProvider;
34
use Syscodes\Core\Http\Exceptions\HttpException;
35
use Syscodes\Core\Http\Exceptions\NotFoundHttpException;
36
use Syscodes\Contracts\Core\Application as ApplicationContract;
37
38
/**
39
 * Allows the loading of service providers and functions to activate 
40
 * routes, environments and calls of main classes.
41
 * 
42
 * @author Alexander Campo <[email protected]>
43
 */
44
class Application extends Container implements ApplicationContract
45
{
46
    /**
47
     * The current globally available application.
48
     * 
49
     * @var string $instance
50
     */
51
    protected static $instance;
52
53
    /**
54
     * Php version.
55
     */
56
    protected static $phpVersion = '7.3.12';
57
    
58
    /**
59
     * The custom application path defined by the developer.
60
     *
61
     * @var string $appPath
62
     */
63
    protected $appPath;
64
65
    /**
66
     * The base path for the Lenevor installation.
67
     *
68
     * @var string $basePath
69
     */
70
    protected $basePath;
71
72
    /**
73
     * Indicates if the application has 'booted'.
74
     * 
75
     * @var bool $booted
76
     */
77
    protected $booted = false;
78
79
    /**
80
     * The array of booted callbacks.
81
     * 
82
     * @var callable[] $bootedCallbacks
83
     */
84
    protected $bootedCallbacks = [];
85
86
    /**
87
     * The array of booting callbacks.
88
     * 
89
     * @var callable[] $bootingCallbacks
90
     */
91
    protected $bootingCallbacks = [];
92
93
    /**
94
     * Get the current application environment.
95
     * 
96
     * @var string
97
     */
98
    protected $env;
99
100
    /**
101
     * The custom environment path defined by the developer.
102
     *
103
     * @var string $environmentPath
104
     */
105
    protected $environmentPath;
106
107
    /**
108
     * The environment file to load during bootstrapping.
109
     *
110
     * @var string $environmentFile
111
     */
112
    protected $environmentFile = '.env';
113
114
    /** 
115
     * Indicates if the application has been bootstrapped before.
116
     * 
117
     * @var bool $hasBeenBootstrapped
118
     */
119
    protected $hasBeenBootstrapped = false;
120
121
    /**
122
     * Indicates if the application is running in the console.
123
     * 
124
     * @var bool|null $isRunningInConsole
125
     */
126
    protected $isRunningInConsole;
127
128
    /**
129
     * The names of the loaded service providers.
130
     * 
131
     * @var array $loadServiceProviders
132
     */
133
    protected $loadServiceProviders = [];
134
135
    /**
136
     * All of the registered services providers.
137
     * 
138
     * @var \Syscodes\Support\ServiceProvider[] $serviceProviders
139
     */
140
    protected $serviceProviders = [];
141
142
    /**
143
     * Constructor. Create a new Application instance.
144
     * 
145
     * @param  string|null  $path 
146
     * 
147
     * @return void
148
     */
149
    public function __construct($path = null)
150
    {
151
        if ($path)
152
        {
153
            $this->setBasePath($path);
154
        }
155
156
        $this->registerBaseBindings();
157
        $this->registerBaseServiceProviders();
158
        $this->registerCoreContainerAliases();
159
        $this->requerimentVersion(static::$phpVersion);
160
        $this->getExtensionLoaded(['mbstring']);
161
    }
162
163
    /**
164
     * Throw an HttpException with the given data.
165
     *
166
     * @param  int  $code
167
     * @param  string  $message
168
     * @param  array  $headers
169
     * 
170
     * @return void
171
     *
172
     * @throws \Syscodes\Core\Http\Exceptions\NotFoundHttpException
173
     * @throws \Syscodes\Core\Http\Exceptions\HttpException
174
     */
175
    public function abort($code, $message = '', array $headers = [])
176
    {
177
        // Convert the first letter in capital
178
        $message = ucfirst($message);
179
180
        if ($code == 404) {
181
            throw new NotFoundHttpException($message);
182
        }
183
184
        throw new HttpException($code, $message, null, $headers);
185
    } 
186
187
    /**
188
     * Set the base path for the application.
189
     *
190
     * @param  string  $path
191
     * 
192
     * @return $this
193
     */
194
    public function setBasePath(string $path)
195
    {
196
        $this->basePath = rtrim($path, '\/');
197
198
        $this->bindContainerPaths();
199
200
        return $this;
201
    }
202
    
203
    /**
204
     * Register all of the base service providers.
205
     * 
206
     * @return void
207
     */
208
    protected function registerBaseServiceProviders()
209
    {
210
        $this->register(new EventServiceProvider($this));
211
        $this->register(new LoggerServiceProvider($this));
212
        $this->register(new RoutingServiceProvider($this));
213
    }
214
215
    /**
216
     * Bind all of the application paths in the container.
217
     * 
218
     * @return void
219
     */
220
    protected function bindContainerPaths()
221
    {
222
        $this->instance('path', $this->path());
223
        $this->instance('path.base', $this->basePath());
224
        $this->instance('path.lang', $this->langPath());
225
        $this->instance('path.config', $this->configPath());
226
        $this->instance('path.public', $this->publicPath());
227
        $this->instance('path.storage', $this->storagePath());
228
        $this->instance('path.database', $this->databasePath());
229
        $this->instance('path.resources', $this->resourcePath());
230
        $this->instance('path.bootstrap', $this->bootstrapPath());
231
    }
232
233
    /**
234
     * Get the path to the application "app" directory.
235
     *
236
     * @param  string  $path
237
     * 
238
     * @return string
239
     */
240
    public function path($path = '')
241
    {
242
        $appPath = $this->basePath.DIRECTORY_SEPARATOR.'app';
243
        
244
        return $appPath.($path ? DIRECTORY_SEPARATOR.$path : $path);
245
    }
246
247
    /**
248
     * Get the base path of the Lenevor installation.
249
     *
250
     * @param  string  $path  Optionally, a path to append to the base path
251
     * 
252
     * @return string
253
     */
254
    public function basePath($path = '')
255
    {
256
        return $this->basePath.($path ? DIRECTORY_SEPARATOR.$path : $path);
257
    }
258
    
259
    /**
260
     * Get the path to the bootstrap directory.
261
     *
262
     * @param  string  $path  Optionally, a path to append to the bootstrap path
263
     * 
264
     * @return string
265
     */
266
    public function bootstrapPath($path = '')
267
    {
268
        return $this->basePath.DIRECTORY_SEPARATOR.'bootstrap'.($path ? DIRECTORY_SEPARATOR.$path : $path);
269
    }
270
271
    /**
272
     * Get the path to the application configuration files.
273
     *
274
     * @param  string  $path  Optionally, a path to append to the config path
275
     * 
276
     * @return string
277
     */
278
    public function configPath($path = '')
279
    {
280
        return $this->basePath.DIRECTORY_SEPARATOR.'config'.($path ? DIRECTORY_SEPARATOR.$path : $path);
281
    }
282
283
    /**
284
     * Get the path to the database directory.
285
     *
286
     * @param  string  $path  Optionally, a path to append to the database path
287
     * 
288
     * @return string
289
     */
290
    public function databasePath($path = '')
291
    {
292
        return $this->basePath.DIRECTORY_SEPARATOR.'database'.($path ? DIRECTORY_SEPARATOR.$path : $path);
293
    }
294
295
    /**
296
     * Get the path to the lang directory.
297
     * 
298
     * @return string
299
     */
300
    public function langPath()
301
    {
302
        return $this->resourcePath().DIRECTORY_SEPARATOR.'lang';
303
    }
304
305
    /**
306
     * Get the path to the public / web directory.
307
     * 
308
     * @return string
309
     */
310
    public function publicPath()
311
    {
312
        return $this->basePath.DIRECTORY_SEPARATOR.'public';
313
    }
314
315
    /**
316
     * Get the path to the resources directory.
317
     *
318
     * @param  string  $path $path  Optionally, a path to append to the resources path
319
     * 
320
     * @return string
321
     */
322
    public function resourcePath($path = '')
323
    {
324
        return $this->basePath.DIRECTORY_SEPARATOR.'resources'.($path ? DIRECTORY_SEPARATOR.$path : $path);
325
    }
326
327
    /**
328
     * Get the path to the storage directory.
329
     * 
330
     * @return string
331
     */
332
    public function storagePath()
333
    {
334
        return $this->basePath.DIRECTORY_SEPARATOR.'storage';
335
    }
336
337
    /**
338
     * Run the given array of bootstap classes.
339
     * 
340
     * @param  string[]  $bootstrappers
341
     * 
342
     * @return void
343
     */
344
    public function bootstrapWith(array $bootstrappers)
345
    {
346
        $this->hasBeenBootstrapped = true;
347
348
        foreach ($bootstrappers as $bootstrapper) {
349
            $this->make($bootstrapper)->bootstrap($this);
350
        }
351
    }
352
353
    /**
354
     * Determine if middleware has been disabled for the application.
355
     * 
356
     * @return bool
357
     */
358
    public function skipGoingMiddleware()
359
    {
360
        return $this->bound('middleware.disable') &&
361
               $this->make('middleware.disable') === true;
362
    }
363
364
    /**
365
     * Set the directory for the environment file.
366
     * 
367
     * @param  string  $path
368
     * 
369
     * @return $this
370
     */
371
    public function setEnvironmentPath($path)
372
    {
373
        $this->environmentPath = $path;
374
375
        return $this;
376
    }
377
378
    /**
379
     * Get the path to the environment file directory.
380
     * 
381
     * @return string
382
     */
383
    public function environmentPath()
384
    {
385
        return $this->environmentPath ?: $this->basePath;
386
    }
387
388
    /**
389
     * Set the environment file to be loaded during bootstrapping.
390
     * 
391
     * @param  string  $file
392
     * 
393
     * @return $this
394
     */
395
    public function setEnvironmentFile($file)
396
    {
397
        $this->environmentFile = $file;
398
399
        return $this;
400
    }
401
402
    /**
403
     * Get the environment file the application is using.
404
     * 
405
     * @return string
406
     */
407
    public function environmentFile()
408
    {
409
        return $this->environmentFile ?: '.env';
410
    }
411
    
412
    /**
413
     * Get the fully qualified path to the environment file.
414
     * 
415
     * @return string
416
     */
417
    public function environmentFilePath()
418
    {
419
        return $this->environmentPath().DIRECTORY_SEPARATOR.$this->environmentFile();
420
    }
421
422
    /**
423
     * Get or check the current application environment.
424
     * 
425
     * @param  string|array  ...$environments
426
     * 
427
     * @return string|bool
428
     */
429
    public function environment(...$environments)
430
    {
431
        if (count($environments) > 0) {
432
            $patterns = is_array($environments[0]) ? $environments[0] : $environments;
433
434
            return Str::is($patterns, $this->env);
0 ignored issues
show
Bug introduced by
$patterns of type array|array<integer,array|string> is incompatible with the type string expected by parameter $pattern of Syscodes\Support\Str::is(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

434
            return Str::is(/** @scrutinizer ignore-type */ $patterns, $this->env);
Loading history...
435
        }
436
437
        return $this->env;
438
    }
439
440
    /**
441
     * Detect the application's current environment.
442
     * 
443
     * @param  \Closure  $callback
444
     *
445
     * @return string
446
     */
447
    public function detectEnvironment(Closure $callback)
448
    {
449
        return $this->env = (new EnvironmentDetector)->detect($callback);
450
    }
451
    
452
    /**
453
     * Determine if application is in local environment.
454
     * 
455
     * @return bool
456
     */
457
    public function isLocal()
458
    {
459
        return $this->env === 'local';
460
    }
461
    
462
    /**
463
     * Determine if application is in production environment.
464
     * 
465
     * @return bool
466
     */
467
    public function isProduction()
468
    {
469
        return $this->env === 'production';
470
    }
471
    
472
    /**
473
     * Determine if the application is unit tests.
474
     * 
475
     * @return bool
476
     */
477
    public function isUnitTests()
478
    {
479
        return $this->env === 'testing';
480
    }
481
482
    /**
483
     * Determine if the application is running in the console.
484
     * 
485
     * @return bool|null
486
     */
487
    public function runningInConsole()
488
    {
489
        if (null === $this->isRunningInConsole) {
490
            $this->isRunningInConsole = Environment::get('APP_RUNNING_CONSOLE') ?? isCli();
0 ignored issues
show
Documentation Bug introduced by
It seems like Syscodes\Support\Environ...NG_CONSOLE') ?? isCli() can also be of type string. However, the property $isRunningInConsole is declared as type boolean|null. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
491
        }
492
493
        return $this->isRunningInConsole;
494
    }
495
    
496
    /**
497
     * You can load different configurations depending on your
498
     * current environment. Setting the environment also influences
499
     * things like logging and error reporting.
500
     * 
501
     * This can be set to anything, but default usage is:
502
     *     local (development)
503
     *     testing
504
     *     production
505
     * 
506
     * @return string
507
     */
508
    public function bootEnvironment()
509
    {
510
        if (file_exists(SYS_PATH.'src'.DIRECTORY_SEPARATOR.'environment'.DIRECTORY_SEPARATOR.$this->environment().'.php')) {
511
            require_once SYS_PATH.'src'.DIRECTORY_SEPARATOR.'environment'.DIRECTORY_SEPARATOR.$this->environment().'.php';
512
        } else {
513
            header('HTTP/1.1 503 Service Unavailable.', true, 503);
514
            print('<style>
515
                    body {
516
                        align-items: center;
517
                        background: #FBFCFC;
518
                        display: flex;
519
                        font-family: verdana, sans-seif;
520
                        font-size: .9em;
521
                        font-weight: 600;
522
                        justify-content: center;
523
                    }
524
                    
525
                    p {
526
                        background: #F0F3F4;
527
                        border-radius: 5px;
528
                        box-shadow: 0 1px 4px #333333;
529
                        color: #34495E;
530
                        padding: 10px;
531
                        text-align: center;
532
                        text-shadow: 0 1px 0 #424949;
533
                        width: 25%;
534
                    }
535
                </style>
536
                <p>The application environment is not set correctly.</p>');
537
            die(); // EXIT_ERROR
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
538
        }
539
    }
540
541
    /**
542
     * Determine if the application has been bootstrapped before.
543
     * 
544
     * @return bool
545
     */
546
    public function hasBeenBootstrapped()
547
    {
548
        return $this->hasBeenBootstrapped;
549
    }
550
551
    /**
552
     * You can empty out this file, if you are certain that you match all requirements.
553
     * You can remove this if you are confident that your PHP version is sufficient.
554
     * 
555
     * @return string
556
     */
557
    protected function requerimentVersion($version)
558
    {
559
        if (version_compare(PHP_VERSION, $version) < 0) {
560
            if (PHP_SAPI == 'cli') {
561
                $string  = "\033[1;36m";
562
                $string .= "$version\033[0m";
563
                trigger_error("Your PHP version must be equal or higher than {$string} to use Lenevor Framework.".PHP_EOL, E_USER_ERROR);
564
            }
565
    
566
            die("Your PHP version must be equal or higher than <b>{$version}</b> to use Lenevor Framework.");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
567
        }
568
    }
569
570
    /**
571
     * You can remove this if you are confident you have mbstring installed.
572
     * 
573
     * @return string
574
     */
575
    protected function getExtensionLoaded(array $extensionLoaded)
576
    {
577
        foreach ($extensionLoaded as $value) {
578
            if ( ! extension_loaded($value)) {
579
                if (PHP_SAPI == 'cli') {
580
                    $string  = "\033[1;36m";
581
                    $string .= "$value\033[0m";
582
                    trigger_error("You must enable the {$string} extension to use Lenevor Framework.".PHP_EOL, E_USER_ERROR);
583
                }
584
585
                die("You must enable the <b>{$value}</b> extension to use Lenevor Framework.");
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
586
            }
587
        }
588
    }
589
590
    /**
591
     * Resolve the given type from the container.
592
     *
593
     * (Overriding Container::make)
594
     * 
595
     * @param  string  $id
596
     * @param  array   $parameters
597
     * 
598
     * @return mixed
599
     */
600
    public function make($id, array $parameters = [])
601
    {
602
        $id = $this->getAlias($id);
603
       
604
        return parent::make($id, $parameters);
605
    }
606
607
    /**
608
     * Register all of the configured providers.
609
     * 
610
     * @return void
611
     */
612
    public function registerConfiguredProviders()
613
    {
614
        (new ProviderRepository($this))
615
                ->load($this['config']->get('services.providers'));
616
    }
617
    
618
    /**
619
     * Register a service provider.
620
     * 
621
     * @param  \Syscodes\Support\ServiceProvider|string  $provider
622
     * @param  bool  $force
623
     * 
624
     * @return \Syscodes\Support\ServiceProvider
625
     */
626
    public function register($provider, $force = false)
627
    {
628
        if (($registered = $this->getProviderHasBeenLoaded($provider)) && ! $force) {
629
            return $registered;
630
        }
631
632
        if (is_string($provider)) {
633
            $provider = $this->resolveProviderClass($provider);
634
        }
635
        
636
        $provider->register();
637
638
        $this->markAsRegistered($provider);
639
640
        return $provider;
641
    }
642
643
    /**
644
     * Get the registered service provider instance if it exists.
645
     * 
646
     * @param  \Syscodes\Support\ServiceProvider|string  $provider
647
     * 
648
     * @return \Syscodes\Support\ServiceProvider
649
     */
650
    protected function getProviderHasBeenLoaded($provider)
651
    {
652
        $name = is_string($provider) ? $provider : get_class($provider);
653
654
        if (array_key_exists($name, $this->loadServiceProviders)) {
655
            return Arr::first($this->serviceProviders, function($key, $value) use ($name) {
656
                return get_class($value) == $name;
657
            });
658
        }
659
    }
660
661
    /**
662
     * Resolve a service provider instance from the class name.
663
     * 
664
     * @param  string  $provider
665
     * 
666
     * @return \Syscodes\Support\ServiceProvider
667
     */
668
    public function resolveProviderClass($provider)
669
    {
670
        return new $provider($this);
671
    }
672
673
    /**
674
     * Mark the given provider as registered.
675
     * 
676
     * @param  \Syscodes\Support\ServiceProvider  $provider
677
     * 
678
     * @return void
679
     */
680
    protected function markAsRegistered($provider)
681
    {
682
        $this->serviceProviders[] = $provider;
683
        
684
        $this->loadServiceProviders[get_class($provider)] = true;
685
    }
686
    
687
    /**
688
     * Determine if the given id type has been bound.
689
     * 
690
     * @param  string  $id
691
     * 
692
     * @return bool
693
     */
694
    public function bound($id)
695
    {
696
        return parent::bound($id);
697
    }
698
699
    /**
700
     * Determine if the application has booted.
701
     * 
702
     * @return bool
703
     */
704
    public function isBooted()
705
    {
706
        return $this->booted;
707
    }
708
709
    /**
710
     * Boot the application´s service providers.
711
     * 
712
     * @return void
713
     */
714
    public function boot()
715
    {
716
        if ($this->isbooted()) {
717
            return;
718
        }
719
720
        $this->bootAppCallbacks($this->bootingCallbacks);
721
722
        array_walk($this->serviceProviders, function ($provider) {
723
            $this->bootProviderClass($provider);
724
        });
725
726
        $this->booted = true;
727
728
        $this->bootAppCallbacks($this->bootedCallbacks);
729
    }
730
731
    /**
732
     * Call the booting callbacks for the application.
733
     * 
734
     * @param  callable[]  $callbacks
735
     * 
736
     * @return void
737
     */
738
    protected function bootAppCallbacks(array $callbacks)
739
    {
740
        foreach ($callbacks as $callback) {
741
            $callback($this);
742
        }
743
    }
744
745
    /**
746
     * Boot the given service provider.
747
     * 
748
     * @param  \Syscodes\Support\ServiceProvider  $provider
749
     * 
750
     * @return mixed
751
     */
752
    protected function bootProviderClass(ServiceProvider $provider)
753
    {
754
        if (method_exists($provider, 'boot'))
755
        {
756
            $provider->boot();
757
        }
758
    }
759
760
    /**
761
     * Register a new boot listener.
762
     * 
763
     * @param  callable  $callback
764
     * 
765
     * @return void
766
     */
767
    public function booting($callback)
768
    {
769
        $this->bootingCallbacks[] = $callback;
770
    }
771
772
    /**
773
     * Register a new 'booted' listener.
774
     * 
775
     * @param  callable  $callback
776
     * 
777
     * @return void
778
     */
779
    public function booted($callback)
780
    {
781
        $this->bootedCallbacks[] = $callback;
782
783
        if ($this->isBooted()) {
784
            $this->bootAppCallbacks([$callback]);
785
        }
786
    }
787
788
    /**
789
     * Get the current application locale.
790
     * 
791
     * @return string
792
     */
793
    public function getLocale()
794
    {
795
        return $this['config']->get('app.locale');
796
    }
797
798
    /**
799
     * Get the current application fallback locale.
800
     * 
801
     * @return string
802
     */
803
    public function getFallbackLocale()
804
    {
805
        return $this['config']->get('app.fallbackLocale');
806
    }
807
808
    /**
809
     * Determine if application locale is the given locale.
810
     * 
811
     * @param  string  $locale
812
     * 
813
     * @return bool
814
     */
815
    public function isLocale($locale)
816
    {
817
        return $this->getLocale() == $locale;
818
    }
819
820
    /**
821
     * Register the basic bindings into the container.
822
     *
823
     * @return void
824
     */
825
    public function registerBaseBindings() 
826
    {
827
        static::setInstance($this);
828
        
829
        $this->instance('app', $this);
830
        
831
        $this->instance('config', $this[\Syscodes\Config\Configure::class]);
832
    }
833
834
    /**
835
     * Register the core class aliases in the container.
836
     * 
837
     * @return void
838
     */
839
    public function registerCoreContainerAliases()
840
    {
841
        foreach ([
842
            'app'              => [self::class, \Syscodes\Contracts\Container\Container::class, \Syscodes\Contracts\Core\Application::class, \Psr\Container\ContainerInterface::class],
843
            'cache'            => [\Syscodes\Cache\CacheManager::class, \Syscodes\Contracts\Cache\Manager::class],
844
            'cache.store'      => [\Syscodes\Cache\CacheRepository::class],
845
            'config'           => [\Syscodes\Config\Configure::class, \Syscodes\Contracts\Config\Configure::class],
846
            'db'               => [\Syscodes\Database\DatabaseManager::class, \Syscodes\Database\ConnectionResolverInterface::class],
847
            'db.connection'    => [\Syscodes\Database\Connection::class, \Syscodes\Database\ConnectionInterface::class],
848
            'encrypter'        => [\Syscodes\Encryption\Encrypter::class, \Syscodes\Contracts\Encryption\Encrypter::class],
849
            'events'           => [\Syscodes\Events\Dispatcher::class, \Syscodes\Contracts\Events\Dispatcher::class],
850
            'files'            => [\Syscodes\Filesystem\Filesystem::class],
851
            'log'              => [\Syscodes\Log\LogManager::class, \Psr\Log\LoggerInterface::class],
852
            'plaze.transpiler' => [\Syscodes\View\Transpilers\PlazeTranspiler::class],
853
            'redirect'         => [\Syscodes\Routing\Redirector::class],
854
            'redis'            => [\Syscodes\Redis\RedisManager::class],
855
            'request'          => [\Syscodes\Http\Request::class],
856
            'router'           => [\Syscodes\Routing\Router::class],
857
            'session'          => [\Syscodes\Session\SessionManager::class],
858
            'session.store'    => [\Syscodes\Session\Store::class, \Syscodes\Contracts\Session\Session::class],
859
            'translator'       => [\Syscodes\Translation\Translator::class],
860
            'url'              => [\Syscodes\Routing\UrlGenerator::class],
861
            'view'             => [\Syscodes\View\Factory::class, \Syscodes\Contracts\View\Factory::class]
862
        ] as $key => $aliases) {
863
            foreach ((array) $aliases as $alias) {
864
                $this->alias($key, $alias);
865
            }
866
        }
867
    }
868
}