Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Checks whether a file or directory exists
<?php file_exists(string $filename): bool
<?php protected function resolveStubPath($stub)
{
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
? $customPath
: __DIR__.$stub;
}
<?php return $this->option('schema-path');
}
if (file_exists($path = database_path('schema/'.$connection->getName().'-schema.dump'))) {
return $path;
}
<?php public function exists($path)
{
return file_exists($path);
}
<?php protected function ensureDirectoryExists($path)
{
if (! file_exists(dirname($path))) {
@mkdir(dirname($path), 0777, true);
}
}
<?php if (file_exists($cached = $app->getCachedConfigPath())) {
$items = require $cached;
$app->instance('config_loaded_from_cache', $loadedFromCache = true);
<?php protected function mergeAdditionalProviders(Application $app)
{
if (static::$bootstrapProviderPath &&
file_exists(static::$bootstrapProviderPath)) {
$packageProviders = require static::$bootstrapProviderPath;
foreach ($packageProviders as $index => $provider) {
<?php $this->app->booted(function () use ($channels, $attributes) {
Broadcast::routes(! empty($attributes) ? $attributes : null);
if (file_exists($channels)) {
require $channels;
}
});
<?php $this->installSanctum();
}
if (file_exists($apiRoutesPath = $this->laravel->basePath('routes/api.php')) &&
! $this->option('force')) {
$this->components->error('API routes file already exists.');
} else {
<?php $this->call('config:publish', ['name' => 'broadcasting']);
if (! file_exists($broadcastingRoutesPath = $this->laravel->basePath('routes/channels.php')) || $this->option('force')) {
$this->components->info("Published 'channels' route file.");
copy(__DIR__.'/stubs/broadcasting-routes.stub', $broadcastingRoutesPath);
<?php $this->enableBroadcastServiceProvider();
if (! file_exists($echoScriptPath = $this->laravel->resourcePath('js/echo.js'))) {
if (! is_dir($directory = $this->laravel->resourcePath('js'))) {
mkdir($directory, 0755, true);
}
<?php copy(__DIR__.'/stubs/echo-js.stub', $echoScriptPath);
}
if (file_exists($bootstrapScriptPath = $this->laravel->resourcePath('js/bootstrap.js'))) {
$bootstrapScript = file_get_contents(
$bootstrapScriptPath
);
<?php $this->components->info('Installing and building Node dependencies.');
if (file_exists(base_path('pnpm-lock.yaml'))) {
$commands = [
'pnpm add --save-dev laravel-echo pusher-js',
'pnpm run build',
<?php 'pnpm add --save-dev laravel-echo pusher-js',
'pnpm run build',
];
} elseif (file_exists(base_path('yarn.lock'))) {
$commands = [
'yarn add --dev laravel-echo pusher-js',
'yarn run build',
<?php 'yarn add --dev laravel-echo pusher-js',
'yarn run build',
];
} elseif (file_exists(base_path('bun.lockb'))) {
$commands = [
'bun add --dev laravel-echo pusher-js',
'bun run build',
<?php protected function resolveStubPath($stub)
{
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
? $customPath
: __DIR__.$stub;
}