Passed
Push — 0.7.0 ( 9dbaae...ecb047 )
by Alexander
03:27 queued 11s
created

Application::skipGoingMiddleware()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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

424
            return Str::is(/** @scrutinizer ignore-type */ $pattern, $this->env);
Loading history...
425
        }
426
427
        return $this->env;
428
    }
429
430
    /**
431
     * Detect the application's current environment.
432
     * 
433
     * @param  \Closure  $callback
434
     *
435
     * @return string
436
     */
437
    public function detectEnvironment(Closure $callback)
438
    {
439
        return $this->env = (new EnvironmentDetector)->detect($callback);
440
    }
441
    
442
    /**
443
     * Determine if application is in local environment.
444
     * 
445
     * @return bool
446
     */
447
    public function isLocal()
448
    {
449
        return $this->env === 'local';
450
    }
451
    
452
    /**
453
     * Determine if application is in production environment.
454
     * 
455
     * @return bool
456
     */
457
    public function isProduction()
458
    {
459
        return $this->env === 'production';
460
    }
461
    
462
    /**
463
     * Determine if the application is unit tests.
464
     * 
465
     * @return bool
466
     */
467
    public function isUnitTests()
468
    {
469
        return $this->env === 'testing';
470
    }
471
    
472
    /**
473
     * You can load different configurations depending on your
474
     * current environment. Setting the environment also influences
475
     * things like logging and error reporting.
476
     * 
477
     * This can be set to anything, but default usage is:
478
     *     local (development)
479
     *     testing
480
     *     production
481
     * 
482
     * @return string
483
     */
484
    public function bootEnvironment()
485
    {
486
        if (file_exists(SYS_PATH.'src'.DIRECTORY_SEPARATOR.'environment'.DIRECTORY_SEPARATOR.$this->environment().'.php')) {
487
            require_once SYS_PATH.'src'.DIRECTORY_SEPARATOR.'environment'.DIRECTORY_SEPARATOR.$this->environment().'.php';
488
        } else {
489
            header('HTTP/1.1 503 Service Unavailable.', true, 503);
490
            print('<style>
491
                    body {
492
                        align-items: center;
493
                        background: #FBFCFC;
494
                        display: flex;
495
                        font-family: verdana, sans-seif;
496
                        font-size: .9em;
497
                        font-weight: 600;
498
                        justify-content: center;
499
                    }
500
                    
501
                    p {
502
                        background: #F0F3F4;
503
                        border-radius: 5px;
504
                        box-shadow: 0 1px 4px #333333;
505
                        color: #34495E;
506
                        padding: 10px;
507
                        text-align: center;
508
                        text-shadow: 0 1px 0 #424949;
509
                        width: 25%;
510
                    }
511
                </style>
512
                <p>The application environment is not set correctly.</p>');
513
            exit; // 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...
514
        }
515
    }
516
517
    /**
518
     * Determine if the application has been bootstrapped before.
519
     * 
520
     * @return bool
521
     */
522
    public function hasBeenBootstrapped()
523
    {
524
        return $this->hasBeenBootstrapped;
525
    }
526
527
    /**
528
     * You can empty out this file, if you are certain that you match all requirements.
529
     * You can remove this if you are confident that your PHP version is sufficient.
530
     * 
531
     * @return string
532
     */
533
    protected function requerimentVersion($version)
534
    {
535
        if (version_compare(PHP_VERSION, $version) < 0) {
536
            if (PHP_SAPI == 'cli') {
537
                $string  = "\033[1;36m";
538
                $string .= "$version\033[0m";
539
                trigger_error("Your PHP version must be equal or higher than {$string} to use Lenevor Framework.".PHP_EOL, E_USER_ERROR);
540
            }
541
    
542
            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...
543
        }
544
    }
545
546
    /**
547
     * You can remove this if you are confident you have mbstring installed.
548
     * 
549
     * @return string
550
     */
551
    protected function getExtensionLoaded(array $extensionLoaded)
552
    {
553
        foreach ($extensionLoaded as $value) {
554
            if ( ! extension_loaded($value)) {
555
                if (PHP_SAPI == 'cli') {
556
                    $string  = "\033[1;36m";
557
                    $string .= "$value\033[0m";
558
                    trigger_error("You must enable the {$string} extension to use Lenevor Framework.".PHP_EOL, E_USER_ERROR);
559
                }
560
561
                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...
562
            }
563
        }
564
    }
565
566
    /**
567
     * Resolve the given type from the container.
568
     *
569
     * (Overriding Container::make)
570
     * 
571
     * @param  string  $id
572
     * @param  array   $parameters
573
     * 
574
     * @return mixed
575
     */
576
    public function make($id, array $parameters = [])
577
    {
578
        $id = $this->getAlias($id);
579
       
580
        return parent::make($id, $parameters);
581
    }
582
583
    /**
584
     * Register all of the configured providers.
585
     * 
586
     * @return void
587
     */
588
    public function registerConfiguredProviders()
589
    {
590
        (new ProviderRepository($this))
591
                ->load($this['config']->get('services.providers'));
592
    }
593
    
594
    /**
595
     * Register a service provider.
596
     * 
597
     * @param  \Syscodes\Support\ServiceProvider|string  $provider
598
     * @param  bool  $force
599
     * 
600
     * @return \Syscodes\Support\ServiceProvider
601
     */
602
    public function register($provider, $force = false)
603
    {
604
        if (($registered = $this->getProviderHasBeenLoaded($provider)) && ! $force) {
605
            return $registered;
606
        }
607
608
        if (is_string($provider)) {
609
            $provider = $this->resolveProviderClass($provider);
610
        }
611
        
612
        $provider->register();
613
614
        $this->markAsRegistered($provider);
615
616
        return $provider;
617
    }
618
619
    /**
620
     * Get the registered service provider instance if it exists.
621
     * 
622
     * @param  \Syscodes\Support\ServiceProvider|string  $provider
623
     * 
624
     * @return \Syscodes\Support\ServiceProvider
625
     */
626
    protected function getProviderHasBeenLoaded($provider)
627
    {
628
        $name = is_string($provider) ? $provider : get_class($provider);
629
630
        if (array_key_exists($name, $this->loadServiceProviders)) {
631
            return Arr::first($this->serviceProviders, function($key, $value) use ($name) {
632
                return get_class($value) == $name;
633
            });
634
        }
635
    }
636
637
    /**
638
     * Resolve a service provider instance from the class name.
639
     * 
640
     * @param  string  $provider
641
     * 
642
     * @return \Syscodes\Support\ServiceProvider
643
     */
644
    public function resolveProviderClass($provider)
645
    {
646
        return new $provider($this);
647
    }
648
649
    /**
650
     * Mark the given provider as registered.
651
     * 
652
     * @param  \Syscodes\Support\ServiceProvider  $provider
653
     * 
654
     * @return void
655
     */
656
    protected function markAsRegistered($provider)
657
    {
658
        $this->serviceProviders[] = $provider;
659
        
660
        $this->loadServiceProviders[get_class($provider)] = true;
661
    }
662
    
663
    /**
664
     * Determine if the given id type has been bound.
665
     * 
666
     * @param  string  $id
667
     * 
668
     * @return bool
669
     */
670
    public function bound($id)
671
    {
672
        return parent::bound($id);
673
    }
674
675
    /**
676
     * Determine if the application has booted.
677
     * 
678
     * @return bool
679
     */
680
    public function isBooted()
681
    {
682
        return $this->booted;
683
    }
684
685
    /**
686
     * Boot the application´s service providers.
687
     * 
688
     * @return void
689
     */
690
    public function boot()
691
    {
692
        if ($this->isbooted()) {
693
            return;
694
        }
695
696
        $this->bootAppCallbacks($this->bootingCallbacks);
697
698
        array_walk($this->serviceProviders, function ($provider) {
699
            $this->bootProviderClass($provider);
700
        });
701
702
        $this->booted = true;
703
704
        $this->bootAppCallbacks($this->bootedCallbacks);
705
    }
706
707
    /**
708
     * Call the booting callbacks for the application.
709
     * 
710
     * @param  callable[]  $callbacks
711
     * 
712
     * @return void
713
     */
714
    protected function bootAppCallbacks(array $callbacks)
715
    {
716
        foreach ($callbacks as $callback) {
717
            $callback($this);
718
        }
719
    }
720
721
    /**
722
     * Boot the given service provider.
723
     * 
724
     * @param  \Syscodes\Support\ServiceProvider  $provider
725
     * 
726
     * @return mixed
727
     */
728
    protected function bootProviderClass(ServiceProvider $provider)
729
    {
730
        if (method_exists($provider, 'boot'))
731
        {
732
            $provider->boot();
733
        }
734
    }
735
736
    /**
737
     * Register a new boot listener.
738
     * 
739
     * @param  callable  $callback
740
     * 
741
     * @return void
742
     */
743
    public function booting($callback)
744
    {
745
        $this->bootingCallbacks[] = $callback;
746
    }
747
748
    /**
749
     * Register a new 'booted' listener.
750
     * 
751
     * @param  callable  $callback
752
     * 
753
     * @return void
754
     */
755
    public function booted($callback)
756
    {
757
        $this->bootedCallbacks[] = $callback;
758
759
        if ($this->isBooted()) {
760
            $this->bootAppCallbacks([$callback]);
761
        }
762
    }
763
764
    /**
765
     * Get the current application locale.
766
     * 
767
     * @return string
768
     */
769
    public function getLocale()
770
    {
771
        return $this['config']->get('app.locale');
772
    }
773
774
    /**
775
     * Get the current application fallback locale.
776
     * 
777
     * @return string
778
     */
779
    public function getFallbackLocale()
780
    {
781
        return $this['config']->get('app.fallbackLocale');
782
    }
783
784
    /**
785
     * Determine if application locale is the given locale.
786
     * 
787
     * @param  string  $locale
788
     * 
789
     * @return bool
790
     */
791
    public function isLocale($locale)
792
    {
793
        return $this->getLocale() == $locale;
794
    }
795
796
    /**
797
     * Register the basic bindings into the container.
798
     *
799
     * @return void
800
     */
801
    public function registerBaseBindings() 
802
    {
803
        static::setInstance($this);
804
        
805
        $this->instance('app', $this);
806
        
807
        $this->instance('config', $this[\Syscodes\Config\Configure::class]);
808
    }
809
810
    /**
811
     * Register the core class aliases in the container.
812
     * 
813
     * @return void
814
     */
815
    public function registerCoreContainerAliases()
816
    {
817
        foreach ([
818
            'app'              => [self::class, \Syscodes\Contracts\Container\Container::class, \Syscodes\Contracts\Core\Application::class, \Psr\Container\ContainerInterface::class],
819
            'cache'            => [\Syscodes\Cache\CacheManager::class, \Syscodes\Contracts\Cache\Manager::class],
820
            'cache.store'      => [\Syscodes\Cache\CacheRepository::class],
821
            'config'           => [\Syscodes\Config\Configure::class, \Syscodes\Contracts\Config\Configure::class],
822
            'db'               => [\Syscodes\Database\DatabaseManager::class, \Syscodes\Database\ConnectionResolverInterface::class],
823
            'db.connection'    => [\Syscodes\Database\Connection::class, \Syscodes\Database\ConnectionInterface::class],
824
            'encrypter'        => [\Syscodes\Encryption\Encrypter::class, \Syscodes\Contracts\Encryption\Encrypter::class],
825
            'events'           => [\Syscodes\Events\Dispatcher::class, \Syscodes\Contracts\Events\Dispatcher::class],
826
            'files'            => [\Syscodes\Filesystem\Filesystem::class],
827
            'log'              => [\Syscodes\Log\LogManager::class, \Psr\Log\LoggerInterface::class],
828
            'plaze.transpiler' => [\Syscodes\View\Transpilers\PlazeTranspiler::class],
829
            'redirect'         => [\Syscodes\Routing\Redirector::class],
830
            'redis'            => [\Syscodes\Redis\RedisManager::class],
831
            'request'          => [\Syscodes\Http\Request::class],
832
            'router'           => [\Syscodes\Routing\Router::class],
833
            'session'          => [\Syscodes\Session\SessionManager::class],
834
            'session.store'    => [\Syscodes\Session\Store::class, \Syscodes\Contracts\Session\Session::class],
835
            'translator'       => [\Syscodes\Translation\Translator::class],
836
            'url'              => [\Syscodes\Routing\UrlGenerator::class],
837
            'view'             => [\Syscodes\View\Factory::class, \Syscodes\Contracts\View\Factory::class]
838
        ] as $key => $aliases) {
839
            foreach ((array) $aliases as $alias) {
840
                $this->alias($key, $alias);
841
            }
842
        }
843
    }
844
}