Allow PHP files in vendor dir to be committed
This commit is contained in:
parent
a9759f1872
commit
49beb2ff64
|
@ -1,9 +1,23 @@
|
|||
# Ignore for safety
|
||||
# Ignore server files for safety
|
||||
.htaccess
|
||||
.htpasswd
|
||||
# Ignore data/ and vendor/
|
||||
|
||||
# Ignore data/
|
||||
data/
|
||||
vendor/
|
||||
|
||||
# Ignore vendor dir except PHP files
|
||||
vendor/*.*
|
||||
vendor/*/*.*
|
||||
vendor/*/*/*.*
|
||||
vendor/*/*/*/*.*
|
||||
vendor/*/*/*/*/*.*
|
||||
vendor/*/*/*/*/*/*.*
|
||||
vendor/**/LICENSE
|
||||
vendor/**/test
|
||||
vendor/**/tst
|
||||
vendor/**/tests
|
||||
!vendor/**/*.php
|
||||
|
||||
# Ignore unit testing logs, api docs and eclipse project files
|
||||
doc/
|
||||
tst/log/
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
// autoload_files.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
|
||||
);
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
$dist = dirname(__DIR__).'/dist';
|
||||
if (!is_dir($dist)) {
|
||||
mkdir($dist, 0755);
|
||||
}
|
||||
if (file_exists($dist.'/random_compat.phar')) {
|
||||
unlink($dist.'/random_compat.phar');
|
||||
}
|
||||
$phar = new Phar(
|
||||
$dist.'/random_compat.phar',
|
||||
FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::KEY_AS_FILENAME,
|
||||
'random_compat.phar'
|
||||
);
|
||||
rename(
|
||||
dirname(__DIR__).'/lib/random.php',
|
||||
dirname(__DIR__).'/lib/index.php'
|
||||
);
|
||||
$phar->buildFromDirectory(dirname(__DIR__).'/lib');
|
||||
rename(
|
||||
dirname(__DIR__).'/lib/index.php',
|
||||
dirname(__DIR__).'/lib/random.php'
|
||||
);
|
||||
|
||||
/**
|
||||
* If we pass an (optional) path to a private key as a second argument, we will
|
||||
* sign the Phar with OpenSSL.
|
||||
*
|
||||
* If you leave this out, it will produce an unsigned .phar!
|
||||
*/
|
||||
if ($argc > 1) {
|
||||
if (!@is_readable($argv[1])) {
|
||||
echo 'Could not read the private key file:', $argv[1], "\n";
|
||||
exit(255);
|
||||
}
|
||||
$pkeyFile = file_get_contents($argv[1]);
|
||||
|
||||
$private = openssl_get_privatekey($pkeyFile);
|
||||
if ($private !== false) {
|
||||
$pkey = '';
|
||||
openssl_pkey_export($private, $pkey);
|
||||
$phar->setSignatureAlgorithm(Phar::OPENSSL, $pkey);
|
||||
|
||||
/**
|
||||
* Save the corresponding public key to the file
|
||||
*/
|
||||
if (!@is_readable($dist.'/random_compat.phar.pubkey')) {
|
||||
$details = openssl_pkey_get_details($private);
|
||||
file_put_contents(
|
||||
$dist.'/random_compat.phar.pubkey',
|
||||
$details['key']
|
||||
);
|
||||
}
|
||||
} else {
|
||||
echo 'An error occurred reading the private key from OpenSSL.', "\n";
|
||||
exit(255);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Simple autoloader that follow the PHP Standards Recommendation #0 (PSR-0)
|
||||
* @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md for more informations.
|
||||
*
|
||||
* Code inspired from the SplClassLoader RFC
|
||||
* @see https://wiki.php.net/rfc/splclassloader#example_implementation
|
||||
*/
|
||||
spl_autoload_register(function($className) {
|
||||
$className = ltrim($className, '\\');
|
||||
if (0 != strpos($className, 'Identicon')) {
|
||||
return false;
|
||||
}
|
||||
$fileName = '';
|
||||
$namespace = '';
|
||||
if ($lastNsPos = strrpos($className, '\\')) {
|
||||
$namespace = substr($className, 0, $lastNsPos);
|
||||
$className = substr($className, $lastNsPos + 1);
|
||||
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
$fileName = __DIR__ . DIRECTORY_SEPARATOR . $fileName . $className . '.php';
|
||||
if (is_file($fileName)) {
|
||||
require $fileName;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
Loading…
Reference in New Issue