}
/**
* Log exception and rethrow it.
*
* @param \Exception $e
* @param string $function
*
* @throws CachePoolException
*/
private function handleException(\Exception $e, $function)
{
$level = 'alert';
if ($e instanceof InvalidArgumentException) {
$level = 'warning';
}
$this->log($level, $e->getMessage(), ['exception' => $e]);
if (!$e instanceof CacheException) {
$e = new CachePoolException(sprintf('Exception thrown when executing "%s". ', $function), 0, $e);
}
throw $e;
}
/**
* @param array $tags
*
* @return bool
*/
public function invalidateTags(array $tags)
{
$itemIds = [];
foreach ($tags as $tag) {
$itemIds = array_merge($itemIds, $this->getList($this->getTagKey($tag)));
}
// Remove all items with the tag
$success = $this->deleteItems($itemIds);
Arguments
"Exception thrown when executing "save". "
if (!$item instanceof PhpCacheItem) {
$e = new InvalidArgumentException('Cache items are not transferable between pools. Item MUST implement PhpCacheItem.');
$this->handleException($e, __FUNCTION__);
}
$this->removeTagEntries($item);
$this->saveTags($item);
$timeToLive = null;
if (null !== $timestamp = $item->getExpirationTimestamp()) {
$timeToLive = $timestamp - time();
if ($timeToLive < 0) {
return $this->deleteItem($item->getKey());
}
}
try {
return $this->storeItemInCache($item, $timeToLive);
} catch (\Exception $e) {
$this->handleException($e, __FUNCTION__);
}
}
/**
* {@inheritdoc}
*/
public function saveDeferred(CacheItemInterface $item)
{
$this->deferred[$item->getKey()] = $item;
return true;
}
/**
* {@inheritdoc}
*/
public function commit()
{
$saved = true;
foreach ($this->deferred as $item) {
Arguments
ErrorException {#309
#message: "file_put_contents(): Only 0 of 265 bytes written, possibly out of free disk space"
#code: 0
#file: "/home/lemp/www/nhakho.vn/sourcecode/vendor/league/flysystem/src/Adapter/Local.php"
#line: 199
#severity: E_WARNING
}
"save"
Arguments
Nwidart\Modules\LaravelModulesServiceProvider {#167}
38
$stream = fopen($location, 'rb');
return ['type' => 'file', 'path' => $path, 'stream' => $stream];
}
/**
* @inheritdoc
*/
public function updateStream($path, $resource, Config $config)
{
return $this->writeStream($path, $resource, $config);
}
/**
* @inheritdoc
*/
public function update($path, $contents, Config $config)
{
$location = $this->applyPathPrefix($path);
$size = file_put_contents($location, $contents, $this->writeFlags);
if ($size === false) {
return false;
}
$type = 'file';
$result = compact('type', 'path', 'size', 'contents');
if ($visibility = $config->get('visibility')) {
$this->setVisibility($path, $visibility);
$result['visibility'] = $visibility;
}
return $result;
}
/**
* @inheritdoc
*/
Arguments
"file_put_contents(): Only 0 of 265 bytes written, possibly out of free disk space"
$stream = fopen($location, 'rb');
return ['type' => 'file', 'path' => $path, 'stream' => $stream];
}
/**
* @inheritdoc
*/
public function updateStream($path, $resource, Config $config)
{
return $this->writeStream($path, $resource, $config);
}
/**
* @inheritdoc
*/
public function update($path, $contents, Config $config)
{
$location = $this->applyPathPrefix($path);
$size = file_put_contents($location, $contents, $this->writeFlags);
if ($size === false) {
return false;
}
$type = 'file';
$result = compact('type', 'path', 'size', 'contents');
if ($visibility = $config->get('visibility')) {
$this->setVisibility($path, $visibility);
$result['visibility'] = $visibility;
}
return $result;
}
/**
* @inheritdoc
*/
Arguments
"/home/lemp/www/nhakho.vn/sourcecode/storage/framework/cache/data/cache/_nhakho_cache_ds_home_ds_lemp_ds_www_ds_nhakho.vn_ds_sourcecode_ds_Modules_ds_Account_ds_module.json"
"a:3:{i:0;a:6:{s:4:"name";s:7:"Account";s:5:"alias";s:7:"account";s:11:"description";s:29:"The FleetCart Account Module.";s:6:"active";i:1;s:5:"order";i:100;s:9:"providers";a:1:{i:0;s:46:"Modules\Account\Providers\RouteServiceProvider";}}i:1;a:0:{}i:2;i:1711731859;}"
2
if ($contents === false) {
return false;
}
$this->delete($path);
return $contents;
}
/**
* @inheritdoc
*/
public function update($path, $contents, array $config = [])
{
$path = Util::normalizePath($path);
$config = $this->prepareConfig($config);
$this->assertPresent($path);
return (bool) $this->getAdapter()->update($path, $contents, $config);
}
/**
* @inheritdoc
*/
public function updateStream($path, $resource, array $config = [])
{
if ( ! is_resource($resource) || get_resource_type($resource) !== 'stream') {
throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
}
$path = Util::normalizePath($path);
$config = $this->prepareConfig($config);
$this->assertPresent($path);
Util::rewindStream($resource);
return (bool) $this->getAdapter()->updateStream($path, $resource, $config);
}
/**
Arguments
"cache/_nhakho_cache_ds_home_ds_lemp_ds_www_ds_nhakho.vn_ds_sourcecode_ds_Modules_ds_Account_ds_module.json"
"a:3:{i:0;a:6:{s:4:"name";s:7:"Account";s:5:"alias";s:7:"account";s:11:"description";s:29:"The FleetCart Account Module.";s:6:"active";i:1;s:5:"order";i:100;s:9:"providers";a:1:{i:0;s:46:"Modules\Account\Providers\RouteServiceProvider";}}i:1;a:0:{}i:2;i:1711731859;}"
League\Flysystem\Config {#308}
return $this->forceClear($key);
}
/**
* {@inheritdoc}
*/
protected function storeItemInCache(PhpCacheItem $item, $ttl)
{
$data = serialize(
[
$item->get(),
$item->getTags(),
$item->getExpirationTimestamp(),
]
);
$file = $this->getFilePath($item->getKey());
if ($this->filesystem->has($file)) {
// Update file if it exists
return $this->filesystem->update($file, $data);
}
try {
return $this->filesystem->write($file, $data);
} catch (FileExistsException $e) {
// To handle issues when/if race conditions occurs, we try to update here.
return $this->filesystem->update($file, $data);
}
}
/**
* @param string $key
*
* @throws InvalidArgumentException
*
* @return string
*/
private function getFilePath($key)
{
if (!preg_match('|^[a-zA-Z0-9_\.! ]+$|', $key)) {
Arguments
"cache/_nhakho_cache_ds_home_ds_lemp_ds_www_ds_nhakho.vn_ds_sourcecode_ds_Modules_ds_Account_ds_module.json"
"a:3:{i:0;a:6:{s:4:"name";s:7:"Account";s:5:"alias";s:7:"account";s:11:"description";s:29:"The FleetCart Account Module.";s:6:"active";i:1;s:5:"order";i:100;s:9:"providers";a:1:{i:0;s:46:"Modules\Account\Providers\RouteServiceProvider";}}i:1;a:0:{}i:2;i:1711731859;}"
public function save(CacheItemInterface $item)
{
if (!$item instanceof PhpCacheItem) {
$e = new InvalidArgumentException('Cache items are not transferable between pools. Item MUST implement PhpCacheItem.');
$this->handleException($e, __FUNCTION__);
}
$this->removeTagEntries($item);
$this->saveTags($item);
$timeToLive = null;
if (null !== $timestamp = $item->getExpirationTimestamp()) {
$timeToLive = $timestamp - time();
if ($timeToLive < 0) {
return $this->deleteItem($item->getKey());
}
}
try {
return $this->storeItemInCache($item, $timeToLive);
} catch (\Exception $e) {
$this->handleException($e, __FUNCTION__);
}
}
/**
* {@inheritdoc}
*/
public function saveDeferred(CacheItemInterface $item)
{
$this->deferred[$item->getKey()] = $item;
return true;
}
/**
* {@inheritdoc}
*/
public function commit()
{
Arguments
Cache\Adapter\Common\CacheItem {#307}
3600
* @return array
* @throws \Psr\Cache\InvalidArgumentException
*/
public function many(array $keys) {
$this->_pullTags();
$items = $this->getWrappedConnection()->getItems(array_map([$this, 'itemKey'], $keys));
return array_map([$this, 'decodeItem'], $items);
}
/**
* Store an item in the cache for a given number of minutes/seconds.
*
* @param string $key
* @param mixed $value
* @param int $duration - seconds for Laravel >= 5.8 or minutes for Laravel <= 5.7
* @return void
* @throws \Psr\Cache\InvalidArgumentException
*/
public function put($key, $value, $duration) {
return $this->getWrappedConnection()->save($this->newItem($key, $value, $this->_pullTags(), $duration));
}
/**
* Store multiple items in the cache for a given number of minutes.
*
* @param array $values
* @param int $duration - seconds for Laravel >= 5.8 or minutes for Laravel <= 5.7
* @return void
*/
public function putMany(array $values, $duration) {
if (!count($values)) {
return;
}
$tags = $this->_pullTags();
foreach ($values as $key => $value) {
$this->getWrappedConnection()->saveDeferred($this->newItem($key, $value, $tags));
}
return $this->getWrappedConnection()->commit();
}
Arguments
Cache\Adapter\Common\CacheItem {#307}
}
/**
* Store an item in the cache.
*
* @param string $key
* @param mixed $value
* @param \DateTimeInterface|\DateInterval|float|int|null $minutes
* @return void
*/
public function put($key, $value, $minutes = null)
{
if (is_array($key)) {
$this->putMany($key, $value);
return;
}
if (! is_null($minutes = $this->getMinutes($minutes))) {
$this->store->put($this->itemKey($key), $value, $minutes);
$this->event(new KeyWritten($key, $value, $minutes));
}
}
/**
* {@inheritdoc}
*/
public function set($key, $value, $ttl = null)
{
$this->put($key, $value, $ttl);
}
/**
* Store multiple items in the cache for a given number of minutes.
*
* @param array $values
* @param \DateTimeInterface|\DateInterval|float|int $minutes
* @return void
*/
Arguments
"/home/lemp/www/nhakho.vn/sourcecode/Modules/Account/module.json"
array:6 [
"name" => "Account"
"alias" => "account"
"description" => "The FleetCart Account Module."
"active" => 1
"order" => 100
"providers" => array:1 [
0 => "Modules\Account\Providers\RouteServiceProvider"
]
]
60
/**
* Get an item from the cache, or execute the given Closure and store the result.
*
* @param string $key
* @param \DateTimeInterface|\DateInterval|float|int $minutes
* @param \Closure $callback
* @return mixed
*/
public function remember($key, $minutes, Closure $callback)
{
$value = $this->get($key);
// If the item exists in the cache we will just return this immediately and if
// not we will execute the given Closure and cache the result of that for a
// given number of minutes so it's available for all subsequent requests.
if (! is_null($value)) {
return $value;
}
$this->put($key, $value = $callback(), $minutes);
return $value;
}
/**
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @param string $key
* @param \Closure $callback
* @return mixed
*/
public function sear($key, Closure $callback)
{
return $this->rememberForever($key, $callback);
}
/**
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @param string $key
Arguments
"/home/lemp/www/nhakho.vn/sourcecode/Modules/Account/module.json"
array:6 [
"name" => "Account"
"alias" => "account"
"description" => "The FleetCart Account Module."
"active" => 1
"order" => 100
"providers" => array:1 [
0 => "Modules\Account\Providers\RouteServiceProvider"
]
]
60
* @param \Closure $callback
* @return $this
*/
public function extend($driver, Closure $callback)
{
$this->customCreators[$driver] = $callback->bindTo($this, $this);
return $this;
}
/**
* Dynamically call the default driver instance.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return $this->store()->$method(...$parameters);
}
}
Arguments
"/home/lemp/www/nhakho.vn/sourcecode/Modules/Account/module.json"
60
Closure() {#306 …4}
* Get file contents as array.
* @return array
* @throws \Exception
*/
public function getAttributes()
{
$attributes = json_decode($this->getContents(), 1);
// any JSON parsing errors should throw an exception
if (json_last_error() > 0) {
throw new InvalidJsonException('Error processing file: ' . $this->getPath() . '. Error: ' . json_last_error_msg());
}
if (config('modules.cache.enabled') === false) {
return $attributes;
}
return app('cache')->remember($this->getPath(), config('modules.cache.lifetime'), function () use ($attributes) {
return $attributes;
});
}
/**
* Convert the given array data to pretty json.
*
* @param array $data
*
* @return string
*/
public function toJsonPretty(array $data = null)
{
return json_encode($data ?: $this->attributes, JSON_PRETTY_PRINT);
}
/**
* Update json contents from array data.
*
* @param array $data
*
* @return bool
Arguments
"remember"
array:3 [
0 => "/home/lemp/www/nhakho.vn/sourcecode/Modules/Account/module.json"
1 => 60
2 => Closure() {#306 …4}
]
protected $filesystem;
/**
* The attributes collection.
*
* @var \Illuminate\Support\Collection
*/
protected $attributes;
/**
* The constructor.
*
* @param mixed $path
* @param \Illuminate\Filesystem\Filesystem $filesystem
*/
public function __construct($path, Filesystem $filesystem = null)
{
$this->path = (string) $path;
$this->filesystem = $filesystem ?: new Filesystem();
$this->attributes = Collection::make($this->getAttributes());
}
/**
* Get filesystem.
*
* @return Filesystem
*/
public function getFilesystem()
{
return $this->filesystem;
}
/**
* Set filesystem.
*
* @param Filesystem $filesystem
*
* @return $this
*/
public function setFilesystem(Filesystem $filesystem)
* @return $this
*/
public function setPath($path)
{
$this->path = (string) $path;
return $this;
}
/**
* Make new instance.
*
* @param string $path
* @param \Illuminate\Filesystem\Filesystem $filesystem
*
* @return static
*/
public static function make($path, Filesystem $filesystem = null)
{
return new static($path, $filesystem);
}
/**
* Get file content.
*
* @return string
*/
public function getContents()
{
return $this->filesystem->get($this->getPath());
}
/**
* Get file contents as array.
* @return array
* @throws \Exception
*/
public function getAttributes()
{
$attributes = json_decode($this->getContents(), 1);
Arguments
"/home/lemp/www/nhakho.vn/sourcecode/Modules/Account/module.json"
null
abstract protected function createModule(...$args);
/**
* Get & scan all modules.
*
* @return array
*/
public function scan()
{
$paths = $this->getScanPaths();
$modules = [];
foreach ($paths as $key => $path) {
$manifests = $this->app['files']->glob("{$path}/module.json");
is_array($manifests) || $manifests = [];
foreach ($manifests as $manifest) {
$name = Json::make($manifest)->get('name');
$modules[$name] = $this->createModule($this->app, $name, dirname($manifest));
}
}
return $modules;
}
/**
* Get all modules.
*
* @return array
*/
public function all() : array
{
if (!$this->config('cache.enabled')) {
return $this->scan();
}
return $this->formatCached($this->getCached());
Arguments
"/home/lemp/www/nhakho.vn/sourcecode/Modules/Account/module.json"
/**
* Get cached modules.
*
* @return array
*/
public function getCached()
{
return $this->app['cache']->remember($this->config('cache.key'), $this->config('cache.lifetime'), function () {
return $this->toCollection()->toArray();
});
}
/**
* Get all modules as collection instance.
*
* @return Collection
*/
public function toCollection() : Collection
{
return new Collection($this->scan());
}
/**
* Get modules by status.
*
* @param $status
*
* @return array
*/
public function getByStatus($status) : array
{
$modules = [];
foreach ($this->all() as $name => $module) {
if ($module->isStatus($status)) {
$modules[$name] = $module;
}
}
return $modules;
$modules = [];
foreach ($cached as $name => $module) {
$path = $module["path"];
$modules[$name] = $this->createModule($this->app, $name, $path);
}
return $modules;
}
/**
* Get cached modules.
*
* @return array
*/
public function getCached()
{
return $this->app['cache']->remember($this->config('cache.key'), $this->config('cache.lifetime'), function () {
return $this->toCollection()->toArray();
});
}
/**
* Get all modules as collection instance.
*
* @return Collection
*/
public function toCollection() : Collection
{
return new Collection($this->scan());
}
/**
* Get modules by status.
*
* @param $status
*
* @return array
*/
/**
* Get an item from the cache, or execute the given Closure and store the result.
*
* @param string $key
* @param \DateTimeInterface|\DateInterval|float|int $minutes
* @param \Closure $callback
* @return mixed
*/
public function remember($key, $minutes, Closure $callback)
{
$value = $this->get($key);
// If the item exists in the cache we will just return this immediately and if
// not we will execute the given Closure and cache the result of that for a
// given number of minutes so it's available for all subsequent requests.
if (! is_null($value)) {
return $value;
}
$this->put($key, $value = $callback(), $minutes);
return $value;
}
/**
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @param string $key
* @param \Closure $callback
* @return mixed
*/
public function sear($key, Closure $callback)
{
return $this->rememberForever($key, $callback);
}
/**
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @param string $key
* @param \Closure $callback
* @return $this
*/
public function extend($driver, Closure $callback)
{
$this->customCreators[$driver] = $callback->bindTo($this, $this);
return $this;
}
/**
* Dynamically call the default driver instance.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return $this->store()->$method(...$parameters);
}
}
Arguments
"kojca-modules"
60
Closure() {#292 …4}
foreach ($cached as $name => $module) {
$path = $module["path"];
$modules[$name] = $this->createModule($this->app, $name, $path);
}
return $modules;
}
/**
* Get cached modules.
*
* @return array
*/
public function getCached()
{
return $this->app['cache']->remember($this->config('cache.key'), $this->config('cache.lifetime'), function () {
return $this->toCollection()->toArray();
});
}
/**
* Get all modules as collection instance.
*
* @return Collection
*/
public function toCollection() : Collection
{
return new Collection($this->scan());
}
/**
* Get modules by status.
*
* @param $status
*
* @return array
*/
public function getByStatus($status) : array
Arguments
"remember"
array:3 [
0 => "kojca-modules"
1 => 60
2 => Closure() {#292 …4}
]
$modules[$name] = $this->createModule($this->app, $name, dirname($manifest));
}
}
return $modules;
}
/**
* Get all modules.
*
* @return array
*/
public function all() : array
{
if (!$this->config('cache.enabled')) {
return $this->scan();
}
return $this->formatCached($this->getCached());
}
/**
* Format the cached data as array of modules.
*
* @param array $cached
*
* @return array
*/
protected function formatCached($cached)
{
$modules = [];
foreach ($cached as $name => $module) {
$path = $module["path"];
$modules[$name] = $this->createModule($this->app, $name, $path);
}
return $modules;
*
* @return Collection
*/
public function toCollection() : Collection
{
return new Collection($this->scan());
}
/**
* Get modules by status.
*
* @param $status
*
* @return array
*/
public function getByStatus($status) : array
{
$modules = [];
foreach ($this->all() as $name => $module) {
if ($module->isStatus($status)) {
$modules[$name] = $module;
}
}
return $modules;
}
/**
* Determine whether the given module exist.
*
* @param $name
*
* @return bool
*/
public function has($name) : bool
{
return array_key_exists($name, $this->all());
}
/**
* Determine whether the given module exist.
*
* @param $name
*
* @return bool
*/
public function has($name) : bool
{
return array_key_exists($name, $this->all());
}
/**
* Get list of enabled modules.
*
* @return array
*/
public function allEnabled() : array
{
return $this->getByStatus(1);
}
/**
* Get list of disabled modules.
*
* @return array
*/
public function allDisabled() : array
{
return $this->getByStatus(0);
}
/**
* Get count from all modules.
*
* @return int
*/
public function count() : int
{
return count($this->all());
Arguments
/**
* Get count from all modules.
*
* @return int
*/
public function count() : int
{
return count($this->all());
}
/**
* Get all ordered modules.
*
* @param string $direction
*
* @return array
*/
public function getOrdered($direction = 'asc') : array
{
$modules = $this->allEnabled();
uasort($modules, function (Module $a, Module $b) use ($direction) {
if ($a->order == $b->order) {
return 0;
}
if ($direction == 'desc') {
return $a->order < $b->order ? 1 : -1;
}
return $a->order > $b->order ? 1 : -1;
});
return $modules;
}
/**
* Get a module path.
*
* @return string
return $modules;
}
/**
* Get a module path.
*
* @return string
*/
public function getPath() : string
{
return $this->path ?: $this->config('paths.modules', base_path('Modules'));
}
/**
* Register the modules.
*/
public function register()
{
foreach ($this->getOrdered() as $module) {
$module->register();
}
}
/**
* Boot the modules.
*/
public function boot()
{
foreach ($this->getOrdered() as $module) {
$module->boot();
}
}
/**
* Find a specific module.
* @param $name
* @return mixed|void
*/
public function find($name)
namespace Nwidart\Modules\Providers;
use Illuminate\Support\ServiceProvider;
class BootstrapServiceProvider extends ServiceProvider
{
/**
* Booting the package.
*/
public function boot()
{
$this->app['modules']->boot();
}
/**
* Register the provider.
*/
public function register()
{
$this->app['modules']->register();
}
}
*
* @param \Illuminate\Support\ServiceProvider|string $provider
* @param bool $force
* @return \Illuminate\Support\ServiceProvider
*/
public function register($provider, $force = false)
{
if (($registered = $this->getProvider($provider)) && ! $force) {
return $registered;
}
// If the given "provider" is a string, we will resolve it, passing in the
// application instance automatically for the developer. This is simply
// a more convenient way of specifying your service provider classes.
if (is_string($provider)) {
$provider = $this->resolveProvider($provider);
}
if (method_exists($provider, 'register')) {
$provider->register();
}
// If there are bindings / singletons set as properties on the provider we
// will spin through them and register them with the application, which
// serves as a convenience layer while registering a lot of bindings.
if (property_exists($provider, 'bindings')) {
foreach ($provider->bindings as $key => $value) {
$this->bind($key, $value);
}
}
if (property_exists($provider, 'singletons')) {
foreach ($provider->singletons as $key => $value) {
$this->singleton($key, $value);
}
}
$this->markAsRegistered($provider);
// If the application has already booted, we will call this boot method on
/**
* Booting the package.
*/
public function boot()
{
}
/**
* Register all modules.
*/
public function register()
{
}
/**
* Register all modules.
*/
protected function registerModules()
{
$this->app->register(BootstrapServiceProvider::class);
}
/**
* Register package's namespaces.
*/
protected function registerNamespaces()
{
$configPath = __DIR__ . '/../config/config.php';
$this->mergeConfigFrom($configPath, 'modules');
$this->publishes([
$configPath => config_path('modules.php'),
], 'config');
}
/**
* Register the service provider.
*/
abstract protected function registerServices();
Arguments
Nwidart\Modules\Providers\BootstrapServiceProvider {#283}
<?php
namespace Nwidart\Modules;
use Nwidart\Modules\Support\Stub;
class LaravelModulesServiceProvider extends ModulesServiceProvider
{
/**
* Booting the package.
*/
public function boot()
{
$this->registerNamespaces();
$this->registerModules();
}
/**
* Register the service provider.
*/
public function register()
{
$this->registerServices();
$this->setupStubPath();
$this->registerProviders();
}
/**
* Setup stub path.
*/
public function setupStubPath()
{
Stub::setBasePath(__DIR__ . '/Commands/stubs');
$this->app->booted(function ($app) {
if ($app['modules']->config('stubs.enabled') === true) {
Stub::setBasePath($app['modules']->config('stubs.path'));
}
});
}
class BoundMethod
{
/**
* Call the given Closure / class@method and inject its dependencies.
*
* @param \Illuminate\Container\Container $container
* @param callable|string $callback
* @param array $parameters
* @param string|null $defaultMethod
* @return mixed
*/
public static function call($container, $callback, array $parameters = [], $defaultMethod = null)
{
if (static::isCallableWithAtSign($callback) || $defaultMethod) {
return static::callClass($container, $callback, $parameters, $defaultMethod);
}
return static::callBoundMethod($container, $callback, function () use ($container, $callback, $parameters) {
return call_user_func_array(
$callback, static::getMethodDependencies($container, $callback, $parameters)
);
});
}
/**
* Call a string reference to a class using Class@method syntax.
*
* @param \Illuminate\Container\Container $container
* @param string $target
* @param array $parameters
* @param string|null $defaultMethod
* @return mixed
*
* @throws \InvalidArgumentException
*/
protected static function callClass($container, $target, array $parameters = [], $defaultMethod = null)
{
$segments = explode('@', $target);
// We will assume an @ sign is used to delimit the class name from the method
class BoundMethod
{
/**
* Call the given Closure / class@method and inject its dependencies.
*
* @param \Illuminate\Container\Container $container
* @param callable|string $callback
* @param array $parameters
* @param string|null $defaultMethod
* @return mixed
*/
public static function call($container, $callback, array $parameters = [], $defaultMethod = null)
{
if (static::isCallableWithAtSign($callback) || $defaultMethod) {
return static::callClass($container, $callback, $parameters, $defaultMethod);
}
return static::callBoundMethod($container, $callback, function () use ($container, $callback, $parameters) {
return call_user_func_array(
$callback, static::getMethodDependencies($container, $callback, $parameters)
);
});
}
/**
* Call a string reference to a class using Class@method syntax.
*
* @param \Illuminate\Container\Container $container
* @param string $target
* @param array $parameters
* @param string|null $defaultMethod
* @return mixed
*
* @throws \InvalidArgumentException
*/
protected static function callClass($container, $target, array $parameters = [], $defaultMethod = null)
{
$segments = explode('@', $target);
// We will assume an @ sign is used to delimit the class name from the method
Arguments
array:2 [
0 => Nwidart\Modules\LaravelModulesServiceProvider {#167}
1 => "boot"
]
[]
* @param callable $callback
* @param mixed $default
* @return mixed
*/
protected static function callBoundMethod($container, $callback, $default)
{
if (! is_array($callback)) {
return $default instanceof Closure ? $default() : $default;
}
// Here we need to turn the array callable into a Class@method string we can use to
// examine the container and see if there are any method bindings for this given
// method. If there are, we can call this method binding callback immediately.
$method = static::normalizeMethod($callback);
if ($container->hasMethodBinding($method)) {
return $container->callMethodBinding($method, $callback[0]);
}
return $default instanceof Closure ? $default() : $default;
}
/**
* Normalize the given callback into a Class@method string.
*
* @param callable $callback
* @return string
*/
protected static function normalizeMethod($callback)
{
$class = is_string($callback[0]) ? $callback[0] : get_class($callback[0]);
return "{$class}@{$callback[1]}";
}
/**
* Get all dependencies for a given method.
*
* @param \Illuminate\Container\Container $container
* @param callable|string $callback
/**
* Call the given Closure / class@method and inject its dependencies.
*
* @param \Illuminate\Container\Container $container
* @param callable|string $callback
* @param array $parameters
* @param string|null $defaultMethod
* @return mixed
*/
public static function call($container, $callback, array $parameters = [], $defaultMethod = null)
{
if (static::isCallableWithAtSign($callback) || $defaultMethod) {
return static::callClass($container, $callback, $parameters, $defaultMethod);
}
return static::callBoundMethod($container, $callback, function () use ($container, $callback, $parameters) {
return call_user_func_array(
$callback, static::getMethodDependencies($container, $callback, $parameters)
);
});
}
/**
* Call a string reference to a class using Class@method syntax.
*
* @param \Illuminate\Container\Container $container
* @param string $target
* @param array $parameters
* @param string|null $defaultMethod
* @return mixed
*
* @throws \InvalidArgumentException
*/
protected static function callClass($container, $target, array $parameters = [], $defaultMethod = null)
{
$segments = explode('@', $target);
// We will assume an @ sign is used to delimit the class name from the method
// name. We will split on this @ sign and then build a callable array that
// we can pass right back into the "call" method for dependency binding.
Arguments
Illuminate\Foundation\Application {#2}
array:2 [
0 => Nwidart\Modules\LaravelModulesServiceProvider {#167}
1 => "boot"
]
Closure() {#31 …3}
* @return \Closure
*/
public function wrap(Closure $callback, array $parameters = [])
{
return function () use ($callback, $parameters) {
return $this->call($callback, $parameters);
};
}
/**
* Call the given Closure / class@method and inject its dependencies.
*
* @param callable|string $callback
* @param array $parameters
* @param string|null $defaultMethod
* @return mixed
*/
public function call($callback, array $parameters = [], $defaultMethod = null)
{
return BoundMethod::call($this, $callback, $parameters, $defaultMethod);
}
/**
* Get a closure to resolve the given type from the container.
*
* @param string $abstract
* @return \Closure
*/
public function factory($abstract)
{
return function () use ($abstract) {
return $this->make($abstract);
};
}
/**
* An alias function name for make().
*
* @param string $abstract
* @param array $parameters
Arguments
Illuminate\Foundation\Application {#2}
array:2 [
0 => Nwidart\Modules\LaravelModulesServiceProvider {#167}
1 => "boot"
]
[]
null
array_walk($this->serviceProviders, function ($p) {
$this->bootProvider($p);
});
$this->booted = true;
$this->fireAppCallbacks($this->bootedCallbacks);
}
/**
* Boot the given service provider.
*
* @param \Illuminate\Support\ServiceProvider $provider
* @return mixed
*/
protected function bootProvider(ServiceProvider $provider)
{
if (method_exists($provider, 'boot')) {
return $this->call([$provider, 'boot']);
}
}
/**
* Register a new boot listener.
*
* @param callable $callback
* @return void
*/
public function booting($callback)
{
$this->bootingCallbacks[] = $callback;
}
/**
* Register a new "booted" listener.
*
* @param callable $callback
* @return void
*/
Arguments
array:2 [
0 => Nwidart\Modules\LaravelModulesServiceProvider {#167}
1 => "boot"
]
}
/**
* Boot the application's service providers.
*
* @return void
*/
public function boot()
{
if ($this->booted) {
return;
}
// Once the application has booted we will also fire some "booted" callbacks
// for any listeners that need to do work after this initial booting gets
// finished. This is useful when ordering the boot-up processes we run.
$this->fireAppCallbacks($this->bootingCallbacks);
array_walk($this->serviceProviders, function ($p) {
$this->bootProvider($p);
});
$this->booted = true;
$this->fireAppCallbacks($this->bootedCallbacks);
}
/**
* Boot the given service provider.
*
* @param \Illuminate\Support\ServiceProvider $provider
* @return mixed
*/
protected function bootProvider(ServiceProvider $provider)
{
if (method_exists($provider, 'boot')) {
return $this->call([$provider, 'boot']);
}
}
Arguments
Nwidart\Modules\LaravelModulesServiceProvider {#167}
Arguments
Nwidart\Modules\LaravelModulesServiceProvider {#167}
38
/**
* Boot the application's service providers.
*
* @return void
*/
public function boot()
{
if ($this->booted) {
return;
}
// Once the application has booted we will also fire some "booted" callbacks
// for any listeners that need to do work after this initial booting gets
// finished. This is useful when ordering the boot-up processes we run.
$this->fireAppCallbacks($this->bootingCallbacks);
array_walk($this->serviceProviders, function ($p) {
$this->bootProvider($p);
});
$this->booted = true;
$this->fireAppCallbacks($this->bootedCallbacks);
}
/**
* Boot the given service provider.
*
* @param \Illuminate\Support\ServiceProvider $provider
* @return mixed
*/
protected function bootProvider(ServiceProvider $provider)
{
if (method_exists($provider, 'boot')) {
return $this->call([$provider, 'boot']);
}
}
/**
Arguments
array:45 [
0 => Illuminate\Events\EventServiceProvider {#6}
1 => Illuminate\Log\LogServiceProvider {#8}
2 => Illuminate\Routing\RoutingServiceProvider {#10}
3 => Illuminate\Auth\AuthServiceProvider {#41}
4 => Illuminate\Cookie\CookieServiceProvider {#37}
5 => Illuminate\Database\DatabaseServiceProvider {#51}
6 => Illuminate\Encryption\EncryptionServiceProvider {#58}
7 => Illuminate\Filesystem\FilesystemServiceProvider {#60}
8 => Illuminate\Foundation\Providers\FormRequestServiceProvider {#66}
9 => Illuminate\Foundation\Providers\FoundationServiceProvider {#65}
10 => Illuminate\Pagination\PaginationServiceProvider {#69}
11 => Illuminate\Session\SessionServiceProvider {#73}
12 => Illuminate\View\ViewServiceProvider {#77}
13 => Illuminate\Notifications\NotificationServiceProvider {#81}
14 => Barryvdh\Debugbar\ServiceProvider {#83}
15 => BeyondCode\DumpServer\DumpServerServiceProvider {#87}
16 => BeyondCode\QueryDetector\QueryDetectorServiceProvider {#95}
17 => Igoshev\Captcha\Providers\CaptchaServiceProvider {#97}
18 => Cartalyst\Sentinel\Laravel\SentinelServiceProvider {#99}
19 => Darryldecode\Cart\CartServiceProvider {#114}
20 => Dimsav\Translatable\TranslatableServiceProvider {#116}
21 => Fideloper\Proxy\TrustedProxyServiceProvider {#117}
22 => Intervention\Image\ImageServiceProvider {#118}
23 => Illuminate\Notifications\NexmoChannelServiceProvider {#121}
24 => Laravel\Scout\ScoutServiceProvider {#124}
25 => Illuminate\Notifications\SlackChannelServiceProvider {#126}
26 => Maatwebsite\Excel\ExcelServiceProvider {#128}
27 => Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider {#140}
28 => Carbon\Laravel\ServiceProvider {#146}
29 => Silber\PageCache\LaravelServiceProvider {#147}
30 => Spatie\ResponseCache\ResponseCacheServiceProvider {#150}
31 => AlternativeLaravelCache\Provider\AlternativeCacheStoresServiceProvider {#151}
32 => Tightenco\Ziggy\ZiggyServiceProvider {#153}
33 => Yajra\DataTables\DataTablesServiceProvider {#154}
34 => Collective\Html\HtmlServiceProvider {#160}
35 => FloatingPoint\Stylist\StylistServiceProvider {#159}
36 => Nwidart\Modules\Providers\ConsoleServiceProvider {#170}
37 => Nwidart\Modules\Providers\ContractsServiceProvider {#172}
38 => Nwidart\Modules\LaravelModulesServiceProvider {#167}
39 => FleetCart\Providers\AppServiceProvider {#158}
40 => FleetCart\Providers\RouteServiceProvider {#174}
41 => FleetCart\Providers\EventServiceProvider {#175}
42 => Illuminate\Translation\TranslationServiceProvider {#185}
43 => Illuminate\Validation\ValidationServiceProvider {#254}
44 => Illuminate\Cache\CacheServiceProvider {#286}
]
Closure($p) {#22 …4}
<?php
namespace Illuminate\Foundation\Bootstrap;
use Illuminate\Contracts\Foundation\Application;
class BootProviders
{
/**
* Bootstrap the given application.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function bootstrap(Application $app)
{
$app->boot();
}
}
{
$this->register(new EventServiceProvider($this));
$this->register(new LogServiceProvider($this));
$this->register(new RoutingServiceProvider($this));
}
/**
* Run the given array of bootstrap classes.
*
* @param string[] $bootstrappers
* @return void
*/
public function bootstrapWith(array $bootstrappers)
{
$this->hasBeenBootstrapped = true;
foreach ($bootstrappers as $bootstrapper) {
$this['events']->dispatch('bootstrapping: '.$bootstrapper, [$this]);
$this->make($bootstrapper)->bootstrap($this);
$this['events']->dispatch('bootstrapped: '.$bootstrapper, [$this]);
}
}
/**
* Register a callback to run after loading the environment.
*
* @param \Closure $callback
* @return void
*/
public function afterLoadingEnvironment(Closure $callback)
{
return $this->afterBootstrapping(
LoadEnvironmentVariables::class, $callback
);
}
/**
* Register a callback to run before a bootstrapper.
Arguments
Illuminate\Foundation\Application {#2}
Facade::clearResolvedInstance('request');
$this->bootstrap();
return (new Pipeline($this->app))
->send($request)
->through($this->app->shouldSkipMiddleware() ? [] : $this->middleware)
->then($this->dispatchToRouter());
}
/**
* Bootstrap the application for HTTP requests.
*
* @return void
*/
public function bootstrap()
{
if (! $this->app->hasBeenBootstrapped()) {
$this->app->bootstrapWith($this->bootstrappers());
}
}
/**
* Get the route dispatcher callback.
*
* @return \Closure
*/
protected function dispatchToRouter()
{
return function ($request) {
$this->app->instance('request', $request);
return $this->router->dispatch($request);
};
}
/**
* Call the terminate method on any terminable middleware.
*
Arguments
array:6 [
0 => "Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables"
1 => "Illuminate\Foundation\Bootstrap\LoadConfiguration"
2 => "Illuminate\Foundation\Bootstrap\HandleExceptions"
3 => "Illuminate\Foundation\Bootstrap\RegisterFacades"
4 => "Illuminate\Foundation\Bootstrap\RegisterProviders"
5 => "Illuminate\Foundation\Bootstrap\BootProviders"
]
$this->app['events']->dispatch(
new Events\RequestHandled($request, $response)
);
return $response;
}
/**
* Send the given request through the middleware / router.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
protected function sendRequestThroughRouter($request)
{
$this->app->instance('request', $request);
Facade::clearResolvedInstance('request');
$this->bootstrap();
return (new Pipeline($this->app))
->send($request)
->through($this->app->shouldSkipMiddleware() ? [] : $this->middleware)
->then($this->dispatchToRouter());
}
/**
* Bootstrap the application for HTTP requests.
*
* @return void
*/
public function bootstrap()
{
if (! $this->app->hasBeenBootstrapped()) {
$this->app->bootstrapWith($this->bootstrappers());
}
}
/**
$router->middlewareGroup($key, $middleware);
}
foreach ($this->routeMiddleware as $key => $middleware) {
$router->aliasMiddleware($key, $middleware);
}
}
/**
* Handle an incoming HTTP request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function handle($request)
{
try {
$request->enableHttpMethodParameterOverride();
$response = $this->sendRequestThroughRouter($request);
} catch (Exception $e) {
$this->reportException($e);
$response = $this->renderException($request, $e);
} catch (Throwable $e) {
$this->reportException($e = new FatalThrowableError($e));
$response = $this->renderException($request, $e);
}
$this->app['events']->dispatch(
new Events\RequestHandled($request, $response)
);
return $response;
}
/**
* Send the given request through the middleware / router.
*
Arguments
Illuminate\Http\Request {#42
#json: null
#convertedFiles: null
#userResolver: null
#routeResolver: null
+attributes: Symfony\Component\HttpFoundation\ParameterBag {#44}
+request: Symfony\Component\HttpFoundation\ParameterBag {#50}
+query: Symfony\Component\HttpFoundation\ParameterBag {#50}
+server: Symfony\Component\HttpFoundation\ServerBag {#46}
+files: Symfony\Component\HttpFoundation\FileBag {#47}
+cookies: Symfony\Component\HttpFoundation\ParameterBag {#45}
+headers: Symfony\Component\HttpFoundation\HeaderBag {#48}
#content: null
#languages: null
#charsets: null
#encodings: null
#acceptableContentTypes: array:1 [
0 => "*/*"
]
#pathInfo: null
#requestUri: null
#baseUrl: null
#basePath: null
#method: null
#format: null
#session: null
#locale: null
#defaultLocale: "en"
-preferredFormat: null
-isHostValid: true
-isForwardedValid: true
pathInfo: "/tin-tuc"
requestUri: "/tin-tuc?q=%2Ftin-tuc&sort=latest&page=2"
baseUrl: ""
basePath: ""
method: "GET"
format: "html"
}
*/
$app = require_once __DIR__ . '/../bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
Arguments
Illuminate\Http\Request {#42
#json: null
#convertedFiles: null
#userResolver: null
#routeResolver: null
+attributes: Symfony\Component\HttpFoundation\ParameterBag {#44}
+request: Symfony\Component\HttpFoundation\ParameterBag {#50}
+query: Symfony\Component\HttpFoundation\ParameterBag {#50}
+server: Symfony\Component\HttpFoundation\ServerBag {#46}
+files: Symfony\Component\HttpFoundation\FileBag {#47}
+cookies: Symfony\Component\HttpFoundation\ParameterBag {#45}
+headers: Symfony\Component\HttpFoundation\HeaderBag {#48}
#content: null
#languages: null
#charsets: null
#encodings: null
#acceptableContentTypes: array:1 [
0 => "*/*"
]
#pathInfo: null
#requestUri: null
#baseUrl: null
#basePath: null
#method: null
#format: null
#session: null
#locale: null
#defaultLocale: "en"
-preferredFormat: null
-isHostValid: true
-isForwardedValid: true
pathInfo: "/tin-tuc"
requestUri: "/tin-tuc?q=%2Ftin-tuc&sort=latest&page=2"
baseUrl: ""
basePath: ""
method: "GET"
format: "html"
}