Skip to content

Conversation

joetannenbaum
Copy link
Contributor

This PR checks for any newer versions of the installer on Packagist and offers to self-update for the user if one exists.

It only checks Packagist at most once per 24 hours, and sends the If-Modified-Since header for maximum caching.

@joetannenbaum joetannenbaum marked this pull request as draft September 29, 2025 16:06
@joetannenbaum joetannenbaum marked this pull request as ready for review September 29, 2025 17:49
@taylorotwell taylorotwell merged commit 8fa21f7 into master Sep 30, 2025
19 checks passed
@taylorotwell taylorotwell deleted the check-current-version branch September 30, 2025 10:27
Comment on lines +214 to +215
protected function checkForUpdate(InputInterface $input, OutputInterface $output)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this return early if ! $input->isInteractive()?

Comment on lines +266 to +269
if (confirm(label: 'Would you like to update now?')) {
$this->runCommands(['composer global update laravel/installer'], $input, $output);
$this->proxyLaravelNew($input, $output);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more ways the installer can be installed besides composer and Herd. Obviously these are the major ones (probably 95%+ of users) but it might be reasonable to somehow check if laravel is actually installed via composer.

Not sure how this'd be done on Windows but on Mac/Linux I think this could be as simple as checking that which laravel starts with composer global config home 2>/dev/null.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually using which is dumb, we can get the path to the currently running script (which is what matters here) using realpath($_SERVER['SCRIPT_FILENAME']).

So the check should probably be just: str_starts_with(realpath($_SERVER['SCRIPT_FILENAME']), $composerHome) where $composerHome is the stdout of composer global config home (can also just use --quiet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants