Prepare's the environment for a new build.

@return void
426562
public function prepare()
    {
        $this->taskFileSystemStack()
             ->mkdir($this->getDistDir())
             ->mkdir($this->getTargetDir())
             ->mkdir($this->getReportsDir())
             ->run();
    }
862542
public function beforeCompile(): void
	{
		$builder = $this->getContainerBuilder();

		// Register as services
		foreach ($builder->findByType(IContainerAware::class) as $service) {
			$service->addSetup('setContainer');
		}
	}
1057875
protected function prepareResources()
    {
        $config = realpath(__DIR__.'/../config/config.php');

        $this->mergeConfigFrom($config, 'cartalyst.alerts');

        $this->publishes([
            $config => config_path('cartalyst.alerts.php'),
        ], 'config');
    }
820309
protected function prepareResources()
    {
        // Publish our views
        $this->loadViewsFrom(base_path("resources/views"), 'base');
        $this->publishes([
            __DIR__ .  '/views' => base_path("resources/views")
        ]);

        // Publish our migrations
        $this->publishes([
            __DIR__ .  '/migrations' => base_path("database/migrations")
        ], 'migrations');

        // Publish a config file
        $this->publishes([
            __DIR__ . '/config' => base_path('/config')
        ], 'config');

        // Publish our routes
        $this->publishes([
            __DIR__ .  '/routes.php' => base_path("app/Http/comments_routes.php")
        ], 'routes');

        // Include the routes file
        if(file_exists(base_path("app/Http/comments_routes.php")))
            include base_path("app/Http/comments_routes.php");
    }
696695
public function run()
	{
		$this->say('Building component');

		// Analyze extension structure
		$this->analyze();

		// Prepare directories
		$this->prepareDirectories();

		if ($this->hasAdmin)
		{
			$adminFiles = $this->copyTarget($this->adminPath, $this->getBuildFolder() . "/administrator/components/com_" . $this->getExtensionName());

			$this->addFiles('backend', $adminFiles);
		}

		if ($this->hasFront)
		{
			$frontendFiles = $this->copyTarget($this->frontPath, $this->getBuildFolder() . "/components/com_" . $this->getExtensionName());

			$this->addFiles('frontend', $frontendFiles);
		}

		// Build media (relative path)
		$media = $this->buildMedia("media/com_" . $this->getExtensionName(), 'com_' . $this->getExtensionName());
		$media->run();

		$this->addFiles('media', $media->getResultFiles());

		// Build language files for the component
		$language = $this->buildLanguage("com_" . $this->getExtensionName());
		$language->run();

		// Cli
		if ($this->hasCli)
		{
			$this->buildCli()->run();
		}

		// Update XML and script.php
		$this->createInstaller();

		// Copy XML and script.php to root
		$adminFolder = $this->getBuildFolder() . "/administrator/components/com_" . $this->getExtensionName();
		$xmlFile     = $adminFolder . "/" . $this->getExtensionName() . ".xml";
		$scriptFile  = $adminFolder . "/script.php";

		$this->_copy($xmlFile, $this->getBuildFolder() . "/" . $this->getExtensionName() . ".xml");
		$this->_copy($scriptFile, $this->getBuildFolder() . "/script.php");

		if (file_exists($scriptFile))
		{
			$this->_copy($scriptFile, $this->getBuildFolder() . "/script.php");
		}

		// Copy Readme
		if (is_file(JPATH_BASE . "/docs/README.md"))
		{
			$this->_copy(JPATH_BASE . "/docs/README.md", $this->getBuildFolder() . "/README");
		}

		return true;
	}
934314
public function boot()
    {
        $envFile;
        if(\file_exists(\base_path('.env')))
            $envFile = \base_path('.env');
        else
            $envFile = __DIR__.'/Publish/.env.pub.default';
		$this->publishes([
			__DIR__.'/Publish/publish.php'	=> \config_path('publish.php'),
	        $envFile => \base_path('.env.pub.default'),
	    ]);
    }
58449
protected function initEnvironment()
    {
        mb_internal_encoding('UTF-8');

        if (is_file($this->getFullEnvFilePath())) {
            $env = new DotEnv($this->basePath, $this->getEnvFile(), true);
            $env->load();
        }
    }
794533
public static function start() : void
  {
    $required = Config::$environment;
    $dotenv   = new Dotenv(Config::$root);

    $dotenv->overload();
    $dotenv->required($required);
  }
867263
private function prepareDistDirectory()
	{
		$build = $this->getBuildFolder();

		if (!file_exists($build))
		{
			$this->_mkdir($build);
		}

		$this->cleanup($build);
	}
669225
protected function buildConfig()
    {
        if ($this->buildCache === null) {
            // Read the top config first:
            $built = [];
            $built = array_replace_recursive($built, $this->values['_top']);

            if (array_key_exists($this->environment, $this->values)) {
                $built = array_replace_recursive($built, $this->values[$this->environment]);
            }

            $this->buildCache = $built;
        }

        return $this->buildCache;
    }
1253650
protected function initTwigEnvironment()
    {
        $this->loader = new TwigLoader;

        $useCache = !Config::get('cms.twigNoCache');
        $isDebugMode = Config::get('app.debug', false);
        $strictVariables = Config::get('cms.enableTwigStrictVariables', false);
        $strictVariables = $strictVariables ?? $isDebugMode;
        $forceBytecode = Config::get('cms.forceBytecodeInvalidation', false);

        $options = [
            'auto_reload' => true,
            'debug' => $isDebugMode,
            'strict_variables' => $strictVariables,
        ];

        if ($useCache) {
            $options['cache'] = new Twig_Cache_Filesystem(
                storage_path().'/cms/twig',
                $forceBytecode ? Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION : 0
            );
        }

        $this->twig = new Twig_Environment($this->loader, $options);
        $this->twig->addExtension(new CmsTwigExtension($this));
        $this->twig->addExtension(new SystemTwigExtension);

        if ($isDebugMode) {
            $this->twig->addExtension(new DebugExtension($this));
        }
    }
1230490
protected function configure()
    {
        $this
            ->setName($this->getName())
            ->setDescription($this->getDescription())
            ->addOption(
                'storage',
                null,
                InputOption::VALUE_OPTIONAL,
                'Environment Location Storage',
                $this->getDefaultFileName()
            );
    }
1272275
protected function setDefaultEnvironment() {
		#Using _ENV_ and $_SERVER only as the last chance to guess the environment.
		#User can and should set the environment through constructor or setEnv($env).

		if(isset($this->params['env']))
			return;
		if(defined('_ENV_'))
			$this->params['env'] = _ENV_;
		elseif(file_exists($file = $this->params['root'].'/storage/environment'))
			$this->params['env'] = trim(file_get_contents($file));
		elseif($this->get('consoleMode')) {
			foreach($_SERVER['argv'] as $k=>$v) {
				if($v === '--env' && isset($_SERVER['argv'][$k+1])) {
					$this->params['env'] = $_SERVER['argv'][$k+1];
					return;
				}
			}
			$this->params['env'] = 'dev';
		}
		elseif(php_sapi_name() === 'cli' || (isset($_SERVER['HTTP_HOST']) && ($_SERVER['HTTP_HOST'] == '127.0.0.1' || $_SERVER['HTTP_HOST'] == 'localhost')))
			$this->params['env'] = 'dev';
		else
			$this->params['env'] = 'prod';
	}
1111466
private function set_up_environment() {
		if ( $this->it_has( 'environment' ) ) {
			$this->environment = $this->options['environment'];
		} else {
			$this->environment = defined( 'WP_DEBUG' ) && WP_DEBUG
				? 'development'
				: 'production';
		}
	}
214818
protected function configure()
    {
        $this
        ->setName($this->name)
        ->setDescription($this->description)
        ->setAliases($this->aliases)
        ->addOption(
          'env',
          null,
          InputOption::VALUE_REQUIRED,
          'Set the environment variable file',
          sprintf('%s/%s', getcwd(), '.craftsman')
        );
    }
1186868
protected function prepare()
    {
        if ($this->dir === null) {
            $this->dir = $this->getProject()->getBasedir();
        }

        if ($this->commandline->getExecutable() === null) {
            throw new BuildException(
                'ExecTask: Please provide "executable"'
            );
        }

        // expand any symbolic links first
        try {
            if (!$this->dir->getCanonicalFile()->exists()) {
                throw new BuildException(
                    "The directory '" . (string) $this->dir . "' does not exist"
                );
            }
            if (!$this->dir->getCanonicalFile()->isDirectory()) {
                throw new BuildException(
                    "'" . (string) $this->dir . "' is not a directory"
                );
            }
        } catch (IOException $e) {
            throw new BuildException(
                "'" . (string) $this->dir . "' is not a readable directory"
            );
        }
        $this->currdir = getcwd();
        @chdir($this->dir->getPath());

        $this->commandline->setEscape($this->escape);
    }
818653
public function setup()
    {
        $this->di->set('config', $this->config);

        $this->initEnvironment($this->config);
        $this->initErrorHandler($this->config);
        $this->initLoader($this->config);
        $this->initModules($this->config);
        $this->initRoutes($this->config);
        $this->initServices($this->config);
        $this->initDispatcher();

        $this->application->setDI($this->di);
        DI::setDefault($this->di);

        return $this;
    }