Skip to content

Commit 49e91ae

Browse files
committed
Only use vendor if it is writable.
1 parent d988c59 commit 49e91ae

File tree

3 files changed

+69
-10
lines changed

3 files changed

+69
-10
lines changed

src/Illuminate/Foundation/Application.php

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ public function runningUnitTests()
433433
*/
434434
public function registerConfiguredProviders()
435435
{
436-
$manifestPath = $this->basePath().'/vendor/services.json';
436+
$manifestPath = $this->getCachedServicesPath();
437437

438438
(new ProviderRepository($this, new Filesystem, $manifestPath))
439439
->load($this->config['app.providers']);
@@ -722,7 +722,14 @@ public function configurationIsCached()
722722
*/
723723
public function getCachedConfigPath()
724724
{
725-
return $this->basePath().'/vendor/config.php';
725+
if ($this->vendorIsWritable())
726+
{
727+
return $this->basePath().'/vendor/config.php';
728+
}
729+
else
730+
{
731+
return $this['path.storage'].'/framework/config.php';
732+
}
726733
}
727734

728735
/**
@@ -742,7 +749,58 @@ public function routesAreCached()
742749
*/
743750
public function getCachedRoutesPath()
744751
{
745-
return $this->basePath().'/vendor/routes.php';
752+
if ($this->vendorIsWritable())
753+
{
754+
return $this->basePath().'/vendor/routes.php';
755+
}
756+
else
757+
{
758+
return $this['path.storage'].'/framework/routes.php';
759+
}
760+
}
761+
762+
/**
763+
* Get the path to the cached "compiled.php" file.
764+
*
765+
* @return string
766+
*/
767+
public function getCachedCompilePath()
768+
{
769+
if ($this->vendorIsWritable())
770+
{
771+
return $this->basePath().'/vendor/compiled.php';
772+
}
773+
else
774+
{
775+
return $this->storagePath().'/framework/compiled.php';
776+
}
777+
}
778+
779+
/**
780+
* Get the path to the cached services.json file.
781+
*
782+
* @return string
783+
*/
784+
public function getCachedServicesPath()
785+
{
786+
if ($this->vendorIsWritable())
787+
{
788+
return $this->basePath().'/vendor/services.json';
789+
}
790+
else
791+
{
792+
return $this->storagePath().'/framework/services.json';
793+
}
794+
}
795+
796+
/**
797+
* Determine if vendor path is writable.
798+
*
799+
* @return bool
800+
*/
801+
public function vendorIsWritable()
802+
{
803+
return is_writable($this->basePath().'/vendor');
746804
}
747805

748806
/**

src/Illuminate/Foundation/Console/ClearCompiledCommand.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ class ClearCompiledCommand extends Command {
2525
*/
2626
public function fire()
2727
{
28-
if (file_exists($path = $this->laravel->basePath().'/vendor/compiled.php'))
28+
$compiledPath = $this->laravel->getCachedCompilePath();
29+
$servicesPath = $this->laravel->getCachedServicesPath();
30+
31+
if (file_exists($compiledPath))
2932
{
30-
@unlink($path);
33+
@unlink($compiledPath);
3134
}
3235

33-
if (file_exists($path = $this->laravel->basePath().'/vendor/services.json'))
36+
if (file_exists($servicesPath))
3437
{
35-
@unlink($path);
38+
@unlink($servicesPath);
3639
}
3740
}
3841

src/Illuminate/Foundation/Console/OptimizeCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,9 @@ protected function compileClasses()
8282
{
8383
$this->registerClassPreloaderCommand();
8484

85-
$outputPath = $this->laravel['path.base'].'/vendor/compiled.php';
86-
8785
$this->callSilent('compile', array(
8886
'--config' => implode(',', $this->getClassFiles()),
89-
'--output' => $outputPath,
87+
'--output' => $this->laravel->getCachedCompilePath(),
9088
'--strip_comments' => 1,
9189
));
9290
}

0 commit comments

Comments
 (0)