* conditionally include vendor autoload & dot-env file if exists
This commit is contained in:
6
src/Exceptions/VendorAutoloadException.php
Normal file
6
src/Exceptions/VendorAutoloadException.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php namespace WpsMcloud\Exceptions;
|
||||
|
||||
class VendorAutoloadException extends WpstudioMediaCloudTransformException
|
||||
{
|
||||
|
||||
}
|
@ -13,6 +13,7 @@
|
||||
*/
|
||||
|
||||
use WpsMcloud\Actions;
|
||||
use WpsMcloud\Exceptions\VendorAutoloadException;
|
||||
use WpsMcloud\Pages;
|
||||
use WpsMcloud\Logger;
|
||||
|
||||
@ -30,10 +31,23 @@ add_action('admin_menu', fn () => add_submenu_page(
|
||||
// $ilabClassLoader = new Composer\Autoload\ClassLoader();
|
||||
// $ilabLoader->unregister();
|
||||
|
||||
include 'vendor/autoload.php';
|
||||
$localVendorAutoloadPath = 'vendor/autoload.php';
|
||||
$projectVendorAutoloadPath = ABSPATH . 'vendor/autoload.php';
|
||||
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||
$dotenv->load();
|
||||
if (file_exists($localVendorAutoloadPath)) {
|
||||
include $localVendorAutoloadPath;
|
||||
} elseif (file_exists($projectVendorAutoloadPath)) {
|
||||
include $projectVendorAutoloadPath;
|
||||
} else {
|
||||
throw new VendorAutoloadException('Unable to find appropriate composer autoloader');
|
||||
}
|
||||
|
||||
$dotEnvFile = __DIR__ . '/.env';
|
||||
|
||||
if (file_exists($dotEnvFile)) {
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||
$dotenv->load();
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$logger = new Logger();
|
||||
|
Reference in New Issue
Block a user