Skip to content

Commit

Permalink
Merge pull request #38 from DarkGhostHunter/master
Browse files Browse the repository at this point in the history
Fixes unquoted require autoload path.
  • Loading branch information
DarkGhostHunter committed May 29, 2020
2 parents bf82e6f + 8b7fd69 commit c6cddeb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Help me support this package

ko_fi: DarkGhostHunter
custom: ['https://paypal.me/darkghosthunter']
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Require this using Composer into your project

composer require darkghosthunter/preloader

> This package doesn't requires `ext-opcache` to install. Just be sure to have it [enabled in your application server](https://www.php.net/manual/en/book.opcache.php).
> This package doesn't require `ext-opcache` to install. Just be sure to have it [enabled in your application server](https://www.php.net/manual/en/book.opcache.php).
## Usage

Expand Down Expand Up @@ -209,7 +209,7 @@ Preloader::make()->selfExclude();

#### `memoryLimit()`

By default, Preloader defaults a memory limit of 32MB, which is enough for *most* applications. TThehe Preloader will generate a list of files until that memory limit is reached.
By default, Preloader defaults a memory limit of 32MB, which is enough for *most* applications. The Preloader will generate a list of files until that memory limit is reached.

You can set your own memory limit in **MB**.

Expand Down
2 changes: 1 addition & 1 deletion src/PreloaderCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function compile() : string
'@output' => $this->scriptRealPath(),
'@generated_at' => date('Y-m-d H:i:s e'),
'@autoload' => isset($this->autoloader)
? 'require_once ' . realpath($this->autoloader) : null,
? 'require_once \'' . realpath($this->autoloader) . '\';': null,
'@list' => $this->parseList(),
'@mechanism' => $this->useRequire
? 'require_once $file' : 'opcache_compile_file($file)',
Expand Down
6 changes: 4 additions & 2 deletions tests/PreloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,11 @@ public function test_uses_require_instead_of_compile()

$contents = file_get_contents($this->preloaderPath);

$this->assertStringContainsString('require_once ' . realpath(implode(DIRECTORY_SEPARATOR, [
$path = realpath(implode(DIRECTORY_SEPARATOR, [
$this->workdir, 'autoload.php'
])), $contents);
]));
$expectedRequire = "require_once '$path';";
$this->assertStringContainsString($expectedRequire, $contents);
$this->assertStringContainsString('require_once $file', $contents);
}

Expand Down

0 comments on commit c6cddeb

Please sign in to comment.