Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Move sites out of config #9632

Merged
merged 157 commits into from
Apr 9, 2024
Merged

[5.x] Move sites out of config #9632

merged 157 commits into from
Apr 9, 2024

Conversation

jesseleite
Copy link
Member

@jesseleite jesseleite commented Mar 2, 2024

What is changing...

The idea here is to move sites configuration out of the php config directory, and into content/sites.yaml, so that we can provide a nice GUI for managing your site/sites (since the config directory is meant to be edited by devs only)...

CleanShot 2024-04-04 at 19 00 11

If you need multi-site, you enable it in config/statamic/system.php...

CleanShot 2024-04-03 at 12 08 13

We've also streamlined the php please multisite command to do this for you...

CleanShot 2024-04-04 at 19 02 34

This allows you to manage multiple sites in the cp...

CleanShot 2024-03-14 at 16 48 35

Of course, you can still manage your sites by hand as before, but now that'll be in content/sites.yaml...

CleanShot 2024-03-13 at 23 42 21

TODO...

  • Rip out statamic.sites.sites config
  • Add new statamic.system.multisite config
  • Update Sites class
    • Deprecate old setConfig() method, with deprecated backwards compatibility fallback for addons
    • Add replacement setSites() and setSiteValue() methods
    • Finish massaging yaml in save() method
    • Resolve antlers for dynamic strings when getting sites
      • Ensure raw/unresolved antlers is saved to yaml
  • Add new GUI to manage site/sites
  • Refactor all the things that called config('statamic.sites.sites') to use new yaml sites config
  • Refactor php please multisite command
  • Update script
    • To insert new multisite config into their config/statamic/system.php
    • To move their sites from config/statamic/sites.php to content/sites.yaml
    • To delete config/statamic/sites.php config, since it is no longer needed
  • Tests
    • Update and pass all existing tests
    • Add new test coverage on sites.yaml related stuff
    • Test update script, since this is more critical feature for people
  • Documentation [5.x] Multi-site documentation overhaul docs#1307

Closes statamic/ideas#1080

@jesseleite jesseleite marked this pull request as ready for review April 4, 2024 23:08
We want it to be a singleton otherwise every time its resolved a new version will be newed up, reading the yaml every time etc. Properties set (like current) wont persist across instances.
# Conflicts:
#	tests/FrontendTest.php
@jasonvarga jasonvarga merged commit 11b5c62 into master Apr 9, 2024
31 checks passed
@jasonvarga jasonvarga deleted the move-sites-out-of-config branch April 9, 2024 17:37
@robdekort
Copy link
Contributor

I'm wondering if this should be in the CP nav under Content by default. Perhaps it's better under Tools or Utilities. It's something you rarely need.

@jasonvarga
Copy link
Member

That's a good thought.

@ajnsn
Copy link
Contributor

ajnsn commented May 30, 2024

With more complex site configurations, it is now much more difficult to achieve a reliable result with all these curly brackets as placeholders for URLs etc. - especially if you have also used PHP enums or collections/arrays in the "attributes".

Code analysis and testing also now seem more difficult to achieve.

Is there still a way e.g. to override this sites.yaml using PHP or is something like that planned?

Thanks!

@duncanmcclean
Copy link
Member

We're not planning on adding back a PHP method for configuring sites.

However, in your case, you could potentially override the sites in a service provider, like this:

// app/Providers/AppServiceProvider.php

use Statamic\Facades\Site;
use Statamic\Statamic;

Statamic::booted(function () {
    Site::setSites([
        'default' => [
            'name' => 'Default',
            'locale' => 'en_US',
            'url' => YourEnum::Url,
        ],
    ]);
});

@ajnsn
Copy link
Contributor

ajnsn commented May 30, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Ability to manage sites in CP
5 participants