src/Services/AssetManager.php
private function buildUniqueFile($file)
    {
        // be sure the folder public/build is exist
        $dir = public_path('build');
        if (!file_exists($dir)) {
            if (!make_dir($dir, 0755)) { // @codeCoverageIgnore
                throw new RuntimeException('Unable to create directory ' . $dir); // @codeCoverageIgnore
            } // @codeCoverageIgnore
        }

        // be sure the manifest path is exist
        $dir = dirname($this->manifestFile);
        if (!file_exists($dir)) {
            if (!make_dir($dir, 0755)) {
                throw new RuntimeException('Unable to create directory ' . $dir); // @codeCoverageIgnore
            }
        }

        // generate unique file
        $ext = pathinfo($file, PATHINFO_EXTENSION);
        $uniqueFile = 'build/' . basename($file, '.' . $ext) . '-' . uniqid() . '.' . $ext;
        copy(public_path($file), public_path($uniqueFile));

        // update manifest
        $oldFile = isset($this->manifest[$file]) ? public_path($this->manifest[$file]) : null;
        $this->manifest[$file] = $uniqueFile;
        if (file_put_contents($this->manifestFile, '<?php return ' . var_export($this->manifest, true) . ';' . PHP_EOL, LOCK_EX) === false) {
            throw new RuntimeException(sprintf('Asset Manager was not able to save manifest file "%s"', $this->manifestFile)); // @codeCoverageIgnore
        }

        // delete old unique file
        if ($oldFile !== null && file_exists($oldFile)) {
            unlink($oldFile);
        }
    }
private function buildUniqueFile($file)
    {
        // be sure the folder public/build is exist
        $dir = public_path('build');
        if (!file_exists($dir)) {
            if (!make_dir($dir, 0755)) { // @codeCoverageIgnore
                throw new RuntimeException('Unable to create directory ' . $dir); // @codeCoverageIgnore
            } // @codeCoverageIgnore
        }

        // be sure the manifest path is exist
        $dir = dirname($this->manifestFile);
        if (!file_exists($dir)) {
            if (!make_dir($dir, 0755)) {
                throw new RuntimeException('Unable to create directory ' . $dir); // @codeCoverageIgnore
            }
        }

        // generate unique file
        $ext = pathinfo($file, PATHINFO_EXTENSION);
        $uniqueFile = 'build/' . basename($file, '.' . $ext) . '-' . uniqid() . '.' . $ext;
        copy(public_path($file), public_path($uniqueFile));

        // update manifest
        $oldFile = isset($this->manifest[$file]) ? public_path($this->manifest[$file]) : null;
        $this->manifest[$file] = $uniqueFile;
        if (file_put_contents($this->manifestFile, '<?php return ' . var_export($this->manifest, true) . ';' . PHP_EOL, LOCK_EX) === false) {
            throw new RuntimeException(sprintf('Asset Manager was not able to save manifest file "%s"', $this->manifestFile)); // @codeCoverageIgnore
        }

        // delete old unique file
        if ($oldFile !== null && file_exists($oldFile)) {
            unlink($oldFile);
        }
    }
private function buildUniqueFile ( $ file ) { // be sure the folder public/build is exist $ dir = public_path ( 'build' ) ; if ( ! file_exists ( $ dir ) ) { if ( ! make_dir ( $ dir , 0755 ) ) { // @codeCoverageIgnore throw new RuntimeException ( 'Unable to create directory ' . $ dir ) ; // @codeCoverageIgnore } // @codeCoverageIgnore } // be sure the manifest path is exist $ dir = dirname ( $ this -> manifestFile ) ; if ( ! file_exists ( $ dir ) ) { if ( ! make_dir ( $ dir , 0755 ) ) { throw new RuntimeException ( 'Unable to create directory ' . $ dir ) ; // @codeCoverageIgnore } } // generate unique file $ ext = pathinfo ( $ file , PATHINFO_EXTENSION ) ; $ uniqueFile = 'build/' . basename ( $ file , '.' . $ ext ) . '-' . uniqid ( ) . '.' . $ ext ; copy ( public_path ( $ file ) , public_path ( $ uniqueFile ) ) ; // update manifest $ oldFile = isset ( $ this -> manifest [ $ file ] ) ? public_path ( $ this -> manifest [ $ file ] ) : null ; $ this -> manifest [ $ file ] = $ uniqueFile ; if ( file_put_contents ( $ this -> manifestFile , '<?php return ' . var_export ( $ this -> manifest , true ) . ';' . PHP_EOL , LOCK_EX ) === false ) { throw new RuntimeException ( sprintf ( 'Asset Manager was not able to save manifest file "%s"' , $ this -> manifestFile ) ) ; // @codeCoverageIgnore } // delete old unique file if ( $ oldFile !== null && file_exists ( $ oldFile ) ) { unlink ( $ oldFile ) ; } }
Build an unique file and update the manifest

@param string $file Name of the file relative to public path.
Build an unique file and update the manifest