Update to Composer 2 (#12263)
* Update to Composer 2 No need to roll our own checks anymore since this is now built in. Also limit the update check to once a week. * update * Make Composer wrapper report correct exit code * Update composer_wrapper.php * re-enable extension check Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
parent
591384f321
commit
b7676e4cc8
|
@ -34,44 +34,6 @@ use Toastr;
|
||||||
|
|
||||||
class Checks
|
class Checks
|
||||||
{
|
{
|
||||||
public static function preAutoload()
|
|
||||||
{
|
|
||||||
// Check PHP version otherwise it will just say server error
|
|
||||||
if (version_compare(PHP_VERSION, '7.3', '<')) {
|
|
||||||
self::printMessage(
|
|
||||||
'PHP version 7.3 or newer is required to run LibreNMS',
|
|
||||||
null,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pre-boot dependency check
|
|
||||||
*/
|
|
||||||
public static function postAutoload()
|
|
||||||
{
|
|
||||||
if (! class_exists(\Illuminate\Foundation\Application::class)) {
|
|
||||||
self::printMessage(
|
|
||||||
'Error: Missing dependencies! Run the following command to fix:',
|
|
||||||
'./scripts/composer_wrapper.php install --no-dev',
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function preBoot()
|
|
||||||
{
|
|
||||||
// check php extensions
|
|
||||||
if ($missing = self::missingPhpExtensions()) {
|
|
||||||
self::printMessage(
|
|
||||||
'Missing PHP extensions. Please install and enable them on your LibreNMS server.',
|
|
||||||
$missing,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post boot Toast messages
|
* Post boot Toast messages
|
||||||
*/
|
*/
|
||||||
|
@ -156,18 +118,4 @@ class Checks
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function missingPhpExtensions()
|
|
||||||
{
|
|
||||||
// allow mysqli, but prefer mysqlnd
|
|
||||||
if (! extension_loaded('mysqlnd') && ! extension_loaded('mysqli')) {
|
|
||||||
return ['mysqlnd'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$required_modules = ['mbstring', 'pcre', 'curl', 'xml', 'gd'];
|
|
||||||
|
|
||||||
return array_filter($required_modules, function ($module) {
|
|
||||||
return ! extension_loaded($module);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Http;
|
namespace App\Http;
|
||||||
|
|
||||||
use App\Checks;
|
|
||||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||||
|
|
||||||
class Kernel extends HttpKernel
|
class Kernel extends HttpKernel
|
||||||
|
@ -96,10 +95,4 @@ class Kernel extends HttpKernel
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
\Illuminate\Auth\Middleware\Authorize::class,
|
\Illuminate\Auth\Middleware\Authorize::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function bootstrap()
|
|
||||||
{
|
|
||||||
Checks::preBoot();
|
|
||||||
parent::bootstrap();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
4
artisan
4
artisan
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
define('LARAVEL_START', microtime(true));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Register The Auto Loader
|
| Register The Auto Loader
|
||||||
|
@ -13,7 +15,7 @@
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require __DIR__.'/bootstrap/autoload.php';
|
require __DIR__.'/vendor/autoload.php';
|
||||||
|
|
||||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||||
|
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
define('LARAVEL_START', microtime(true));
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Register The Composer Auto Loader
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Composer provides a convenient, automatically generated class loader
|
|
||||||
| for our application. We just need to utilize it! We'll require it
|
|
||||||
| into the script here so we do not have to manually load any of
|
|
||||||
| our application's PHP classes. It just feels great to relax.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
@require_once __DIR__ . '/../app/Checks.php';
|
|
||||||
\App\Checks::preAutoload();
|
|
||||||
|
|
||||||
@include __DIR__ . '/../vendor/autoload.php';
|
|
||||||
|
|
||||||
\App\Checks::postAutoload();
|
|
|
@ -100,6 +100,7 @@
|
||||||
"optimize-autoloader": true,
|
"optimize-autoloader": true,
|
||||||
"preferred-install": "dist",
|
"preferred-install": "dist",
|
||||||
"sort-packages": true,
|
"sort-packages": true,
|
||||||
|
"platform-check": true,
|
||||||
"discard-changes": true
|
"discard-changes": true
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -22,7 +22,7 @@ you can do so by running the following commands:
|
||||||
```bash
|
```bash
|
||||||
cd /opt/librenms
|
cd /opt/librenms
|
||||||
git pull
|
git pull
|
||||||
composer install --no-dev
|
./scripts/composer_wrapper.php install --no-dev
|
||||||
php includes/sql-schema/update.php
|
php includes/sql-schema/update.php
|
||||||
./validate.php
|
./validate.php
|
||||||
```
|
```
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require __DIR__ . '/../bootstrap/autoload.php';
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
2
lnms
2
lnms
|
@ -13,7 +13,7 @@
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require __DIR__.'/bootstrap/autoload.php';
|
require __DIR__.'/vendor/autoload.php';
|
||||||
|
|
||||||
// Check that we don't run this as the wrong user and break the install
|
// Check that we don't run this as the wrong user and break the install
|
||||||
\App\Checks::runningUser();
|
\App\Checks::runningUser();
|
||||||
|
|
|
@ -55,8 +55,12 @@ if (php_sapi_name() == 'cli' && isset($_SERVER['TERM'])) {
|
||||||
if (is_file($install_dir . '/composer.phar')) {
|
if (is_file($install_dir . '/composer.phar')) {
|
||||||
$exec = PHP_BINDIR . '/php ' . $install_dir . '/composer.phar';
|
$exec = PHP_BINDIR . '/php ' . $install_dir . '/composer.phar';
|
||||||
|
|
||||||
// self-update
|
// If older than 1 week, try update
|
||||||
passthru("$exec self-update -q" . $extra_args);
|
if (time() - filemtime($install_dir . '/composer.phar') > 60 * 60 * 24 * 7) {
|
||||||
|
// self-update
|
||||||
|
passthru("$exec self-update --quiet --2" . $extra_args);
|
||||||
|
touch($install_dir . '/composer.phar');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$sig_url = ($use_https ? 'https' : 'http') . '://composer.github.io/installer.sig';
|
$sig_url = ($use_https ? 'https' : 'http') . '://composer.github.io/installer.sig';
|
||||||
|
|
||||||
|
@ -93,7 +97,8 @@ if (! $exec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($exec) {
|
if ($exec) {
|
||||||
passthru("$exec " . implode(' ', array_splice($argv, 1)) . "$extra_args 2>&1");
|
passthru("$exec " . implode(' ', array_splice($argv, 1)) . "$extra_args 2>&1", $exit_code);
|
||||||
|
exit($exit_code);
|
||||||
} else {
|
} else {
|
||||||
echo "Composer not available, please manually install composer.\n";
|
echo "Composer not available, please manually install composer.\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue