PHP code example of mistralys / composer-local-switcher
1. Go to this page and download the library: Download mistralys/composer-local-switcher library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mistralys / composer-local-switcher example snippets
declare(strict_types=1);
use Mistralys\ComposerSwitcher\ConfigSwitcher;
use Mistralys\ComposerSwitcher\Utils\ConfigFile;
class ComposerScripts
{
public static function switchToDEV() : void
{
self::createSwitcher()->switchToDevelopment();
}
public static function switchToPROD() : void
{
self::createSwitcher()->switchToProduction();
}
public static function switchUpdate() : void
{
self::createSwitcher()->switchUpdate();
}
private static $initialized = false;
/**
* Initializes the Composer autoloader. Scripts do not
* automatically load it, so we need to do it manually.
* Additionally, we ensure that this is only done once
* across multiple script calls.
*/
private static function initAutoloader() : void
{
if(self::$initialized) {
return;
}
self::$initialized = true;
use Mistralys\ComposerSwitcher\ConfigSwitcher;
$switcher = new ConfigSwitcher();
$switcher->setFlagFileEnabled(false);
use Mistralys\ComposerSwitcher\ConfigSwitcher;
$switcher = new ConfigSwitcher();
$switcher->setWriteToConsole(true);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.