Pantheon\Terminus\Commands\Site\CreateCommand::create PHP Method

create() public method

Create a site
public create ( string $site_name, string $label, string $upstream_id, $options = ['org' => null] )
$site_name string Machine name of the site to create (i.e. the slugified name)
$label string A human-readable label for the new site
$upstream_id string UUID or name of the upstream to use in creating this site
    public function create($site_name, $label, $upstream_id, $options = ['org' => null])
    {
        $workflow_options = ['label' => $label, 'site_name' => $site_name];
        $user = $this->session()->getUser();
        // Locate upstream
        $upstream = $user->getUpstreams()->get($upstream_id);
        // Locate organization
        if (!is_null($org_id = $options['org'])) {
            $org = $user->getOrganizations()->get($org_id)->fetch();
            $workflow_options['organization_id'] = $org->id;
        }
        // Create the site
        $this->log()->notice('Creating a new site...');
        $workflow = $this->sites->create($workflow_options);
        while (!$workflow->checkProgress()) {
            // @TODO: Add Symfony progress bar to indicate that something is happening.
        }
        // Deploy the upstream
        if ($site = $this->getSite($site_name)) {
            $this->log()->notice('Deploying CMS...');
            $workflow = $site->deployProduct($upstream->id);
            while (!$workflow->checkProgress()) {
                // @TODO: Add Symfony progress bar to indicate that something is happening.
            }
            $this->log()->notice('Deployed CMS');
        }
    }
CreateCommand