Giter VIP home page Giter VIP logo

wordpress-core-installer's Introduction

WordPress Core Installer

Build Status codecov License: GPL v2 Packagist GitHub tag

A custom Composer plugin to install WordPress core outside of vendor.

This installer is meant to support a rather specific WordPress installation setup in which WordPress is installed in a subdirectory (see the WordPress codex on that subject) and in which the location of WP_CONTENT_DIR and WP_CONTENT_URL have been customized to be outside of WordPress core (see the WordPress codex on that subject). This is because composer will delete your whole wp-content directory every time it updates core if you don't separate the two. If that installation setup isn't what you are looking for, then this installer is probably not something you will want to use.

For more information on this site setup and using Composer to manage a whole WordPress site, check out @Rarst's informational website which also includes a site stack example using this package.

Usage

To set up a custom WordPress build package to use this as a custom installer, add the following to your package's composer file:

"type": "wordpress-core",
"require": {
	"johnpbloch/wordpress-core-installer": "^2.0"
}

If you need to maintain support for PHP versions lower than 5.6 (not recommended!), use ^1.0 as your version constraint in the above.

By default, this package will install a wordpress-core type package in the wordpress directory. To change this you can add the following to either your custom WordPress core type package or the root composer package:

"extra": {
	"wordpress-install-dir": "custom/path"
}

The root composer package can also declare custom paths as an object keyed by package name:

"extra": {
	"wordpress-install-dir": {
		"wordpress/wordpress": "wordpress",
		"johnpbloch/wordpress-core": "jpb-wordpress"
	}
}

License

This is licensed under the GPL version 2 or later.

Changelog

2.0.0
  • Added support for Composer v2. Special thanks to @Ayesh for the original pull request to add this support.
  • Bumped minimum required PHP version to 5.6 (same as WP). If you need to stick with an older PHP version, you're probably ok with also sticking with an older version of Composer and can continue to use ^1.0 as your version constraint.
  • Other various fixes and improvements to README, tests, etc.
1.0.0
  • Initial stable release
  • Added tests and CI
  • Support added for custom vendor directories
  • Added sanity check for overwriting sensitive directories

wordpress-core-installer's People

Contributors

ayesh avatar dangrussell avatar johnpbloch avatar rarst avatar szepeviktor avatar vinkla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wordpress-core-installer's Issues

Apply GPL License Header

https://www.gnu.org/licenses/gpl-howto.html

Whichever [GPL] license you plan to use, the process involves adding two elements to each source file of your program: a copyright notice (such as “Copyright 1999 Terry Jones”), and a statement of copying permission, saying that the program is distributed under the terms of the GNU General Public License (or the Lesser GPL).

Use WP.org repo ZIP-s

@johnpbloch How about writing a Composer plugin that returns the ZIP URL-s from WP.org when wordpress/wordpress-core is required.
Without a repo here on GitHub.

What do you think?

Continued to use ^1.0 as your version constraint no longer possible

As of today installation has started to fail with:

Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.
  Problem 1
    - composer/installers is locked to version v1.8.0 and an update of this package was not requested.
    - composer/installers v1.8.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
  Problem 2
    - johnpbloch/wordpress-core-installer is locked to version 1.0.2 and an update of this package was not requested.
    - johnpbloch/wordpress-core-installer 1.0.2 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
  Problem 3
    - koodimonni/composer-dropin-installer is locked to version 1.2 and an update of this package was not requested.
    - koodimonni/composer-dropin-installer 1.2 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
  Problem 4
    - composer/installers v1.8.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
    - wpackagist-theme/twentynineteen 1.4 requires composer/installers ~1.0 -> satisfiable by composer/installers[v1.8.0].
    - wpackagist-theme/twentynineteen is locked to version 1.4 and an update of this package was not requested.
You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.

Seems like eveybody running "johnpbloch/wordpress-core-installer": "^1.0", will need to update to "johnpbloch/wordpress-core-installer": "^2.0", now.

Improve exception message

For some reason, I'm hitting the exception here. Any chance of making the accompanying message more useful please, like giving a clue as to which packages it thinks are causing the conflicts?

wp-config.php

I'm using a custom wp-config.php that is added by a project generator.

How can I keep this installer from overwriting it, or is it safe?

Only install if directory doesn't exist or is empty

Is it possible to only have it install wordpress if the directory it is trying to install to either doesn't exist or is empty?

For example, we had an issue with one of the packages in our vendor folder and ended up removing the vendor folder. Then upon doing a composer install, it removed the current wordpress installation we had, along with custom themes, plugins etc.

Thanks

Conflict with Composer/Installers?

Installing WordPress Core and a theme.

If I set the core install dir to "./" to install to root it seems to error on loading the composer/installers dependency after core is loaded and it tries to install the theme.

Specifying a subdirectory works fine. It only seems to conflict when it installs to the root. Looks like the dependency (installers) doesn't even load in the directory structure, but it looks like its being downloaded according to the command output.

This was an experiment to see if I could get an install going in a more traditional manner than the WordPress skeleton.

Admin not working after server change

HI, I have used this installer to install wordpress in subdirectory. Everything worked fine on local however once I pushed repo to staging, I am unable to access admin and other url's as well. I hope once I am able to login to admin, I can update permalinks and everything should work fine then.

Admin url - example.com/wordpress/wp-admin does not work.
It shows login when I access it like this: example.com/wordpress/wp-login.php however it redirects to wp-login.php(example.com/wp-login.php) file without having wordpress in front of the url and shows 404 Not Found. I have updated all url's and paths in DB on staging already.

Installer removes all contents with update

Hi,
I'm investigating possibilities of using composer to install wordpress core as a dependency. I looks really nice, however I did notice that the installer always purge the directory when installing/updating core. This proves the whole update process unusable, as all custom plugins or themes are removed as well. No to mention that even custom directories (one with Magento installed) are also removed.
Would it be possible to change that behaviour?

WordPress files get removed with Composer v2

{
    "require": {
        "johnpbloch/wordpress": "^5.5"
    }
}

then issue composer update -vvv

Running 2.0.5 (2020-11-06 20:57:15) with PHP 7.4.12 on Linux / 4.9.0-13-amd64
Loading composer repositories with package information
Updating dependencies
Downloading https://repo.packagist.org/packages.json
[200] https://repo.packagist.org/packages.json
Writing /home/viktor/.composer/cache/repo/https---repo.packagist.org/packages.json into cache
Reading /home/viktor/.composer/cache/repo/https---repo.packagist.org/provider-johnpbloch~wordpress.json from cache
Downloading https://repo.packagist.org/p2/johnpbloch/wordpress.json if modified
[304] https://repo.packagist.org/p2/johnpbloch/wordpress.json
Reading /home/viktor/.composer/cache/repo/https---repo.packagist.org/provider-johnpbloch~wordpress-core-installer.json from cache
Downloading https://repo.packagist.org/p2/johnpbloch/wordpress-core-installer.json if modified
Reading /home/viktor/.composer/cache/repo/https---repo.packagist.org/provider-johnpbloch~wordpress-core.json from cache
Downloading https://repo.packagist.org/p2/johnpbloch/wordpress-core.json if modified
[304] https://repo.packagist.org/p2/johnpbloch/wordpress-core-installer.json
[304] https://repo.packagist.org/p2/johnpbloch/wordpress-core.json
Generating rules
Resolving dependencies through SAT
Looking at all rules.

Dependency resolution completed in 0.001 seconds
Analyzed 102 packages to resolve dependencies
Analyzed 119 rules to resolve dependencies
Lock file operations: 3 installs, 0 updates, 0 removals
Installs: johnpbloch/wordpress-core-installer:2.0.0, johnpbloch/wordpress-core:5.5.3, johnpbloch/wordpress:5.5.3
  - Locking johnpbloch/wordpress (5.5.3)
  - Locking johnpbloch/wordpress-core (5.5.3)
  - Locking johnpbloch/wordpress-core-installer (2.0.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Reading ./composer.lock
Package operations: 3 installs, 0 updates, 0 removals
Installs: johnpbloch/wordpress-core-installer:2.0.0, johnpbloch/wordpress-core:5.5.3, johnpbloch/wordpress:5.5.3
Reading /home/viktor/.composer/cache/files/johnpbloch/wordpress-core-installer/84ce93917e6c7c835605347db4d7b24a35c31b36.zip from cache
  - Loading johnpbloch/wordpress-core-installer (2.0.0) from cache
Reading /home/viktor/.composer/cache/files/johnpbloch/wordpress-core/e85f10502a0a6f4864337a4474036d50e388215f.zip from cache
  - Loading johnpbloch/wordpress-core (5.5.3) from cache
Reading /home/viktor/.composer/cache/files/johnpbloch/wordpress/b8fa87abf133edd70fc2c40d173a209a2ca02d61.zip from cache
  - Loading johnpbloch/wordpress (5.5.3) from cache
  - Installing johnpbloch/wordpress-core-installer (2.0.0): Extracting archive
Executing async command (CWD): unzip -qq  '/home/viktor/src/aaa/vendor/composer/tmp-489c3d55a29081837b520ea3a4b8f684' -d '/home/viktor/src/aaa/vendor/composer/e7189ce9'
Executing command (CWD): rm -rf '/home/viktor/src/aaa/vendor/johnpbloch/wordpress-core-installer'
Executing command (CWD): rm -rf '/home/viktor/src/aaa/vendor/composer/e7189ce9'
Loading plugin johnpbloch\Composer\WordPressCorePlugin
  - Installing johnpbloch/wordpress-core (5.5.3): Extracting archive
Executing async command (CWD): unzip -qq  '/home/viktor/src/aaa/vendor/composer/tmp-27df48c3e76ad610b4feb1a57b7ff83c' -d '/home/viktor/src/aaa/vendor/composer/9ab5b618'
  - Installing johnpbloch/wordpress (5.5.3): Extracting archive
Executing async command (CWD): unzip -qq  '/home/viktor/src/aaa/vendor/composer/tmp-186e3fe3d05bdc276f37ac0b34690add' -d '/home/viktor/src/aaa/vendor/composer/6ddaa97c'
Executing command (CWD): rm -rf '/home/viktor/src/aaa/vendor/johnpbloch/wordpress'
Executing command (CWD): rm -rf '/home/viktor/src/aaa/vendor/composer/6ddaa97c'
Executing command (CWD): rm -rf 'wordpress'
Executing command (CWD): rm -rf '/home/viktor/src/aaa/vendor/composer/9ab5b618'
Executing command (CWD): rm -rf '/home/viktor/src/aaa/wordpress'
Executing command (CWD): rm -rf '/home/viktor/src/aaa/vendor/johnpbloch/wordpress-core'
Downloading https://packagist.org/downloads/
[201] https://packagist.org/downloads/
Generating autoload files

So WP files got removed.

Works with Composer v1.

@johnpbloch Please advise.

[question] when the execution of the script is indicated?

Hello, first congratulations on the package, it works perfectly.
I just had a question about the way it works, in the code, where do you indicate that the script should be executed to make the directory change ?, that is, do you use some type of script as "post-package-install"?
Thank you very much and apologize for this little doubt that I have.

Wordpress not installing with existing composer.lock file

I'm trying to automate my deployments, but I'm noticing when there's a composer.lock file in the project root, when I run composer install, the wordpress-install-dir only has the composer.json and readme.html files. It doesn't actually install wordpress-core. Rather than ignoring the composer.lock file, is there a way to force composer to reinstall wordpress-core?

So with a composer.lock file present, this is the result of running composer install

image

and if I delete the composer.lock file, running composer install gives me this

image

Though deleting the composer.lock file fixes the issue, it seems like it's best practice to commit the composer.lock file (http://stackoverflow.com/questions/12896780/should-composer-lock-be-committed-to-version-control)

Additional example:

  • Download johnpbloch/wordpress-project
  • Run composer install. It'll install wordpress core in public/wp.
  • Commit the project , including the composer.lock file. Note: inside .gitignore, there's a line for public/wp,
  • Clone a fresh copy of the repo (with the composer.lock file)
  • Run composer install
  • Note that it does not install wordpress core to public/wp, just the composer.json and readme.html

Please consider adjusting license to ISC/MIT

Looks like you've produced nice tool many are finding value in, @johnpbloch.

I come from a JS development background and, as I work on my first WordPress plugin, have been noticing some licensing snafus I believe to be rooted in two things:

  1. WordPress not making the switch to GitHub with the rest of the modern universe.
  2. WordPress Foundation's intolerance for leaving license related questions open on the forums.

As a result of some of the licensing issues I've seen I've left some guidance on what I feel the proper structure should be for WP tools and the applications which used them to build themes and plugins here: xwp/wp-dev-lib#240 (comment)

And here's the most current, usable and authoritative reference I've found regarding licensing during my recent searches: https://choosealicense.com/licenses/

folder issue if wp-content created by wpackagist in the same time

Hi,
My composer.json have "johnpbloch/wordpress-core-installer": "^2.0" but also a yoast "yoast/wordpress-seo": "^12.5" installer

So as installation of wordpress take time, yoast create a wp-content folder before wordpress-core-installer finished. So a wp-content folder already exists whan the wordpress install wants to create one.
I think johnpbloch install don't make the right choice when a folder already exists because it ended with wp-content/wp-content/theme
If I remove the plugins, installatyion is correct and I get wp-content/theme
Thank you
Florent

Needs Unit Tests

It was a proof of concept. Now that I've released it, I need to write tests for it.

In all that lovely free time I have...

Fails in project with packages using composer/installers

Install fails if core package, using core installer, is used alongside other package, using composer/installers.

composer.json

{
    "name"        : "rarst/core-install-test",
    "repositories": [
        {
            "type": "composer",
            "url" : "http://wpackagist.org"
        },
        {
            "type"   : "package",
            "package": {
                "name"   : "rarst/wordpress",
                "type"   : "wordpress-core",
                "version": "3.6",
                "dist"   : {
                    "url" : "http://wordpress.org/wordpress-3.6.zip",
                    "type": "zip"
                },
                "source" : {
                    "url"      : "https://github.com/WordPress/WordPress",
                    "type"     : "git",
                    "reference": "3.6"
                },
                "require": {
                    "johnpbloch/wordpress-core-installer": "~0.1"
                }
            }
        }
    ],
    "require"     : {
        "rarst/wordpress"                  : ">=3.6",
        "wpackagist/toolbar-theme-switcher": "*"
    }
}

Install log ends up in


  [InvalidArgumentException]
  Package type "wordpress-core" is not supported



Exception trace:
 () at C:\server\core-installer-test\vendor\composer\installers\src\Composer\Installers\BaseInstaller.php:63
 Composer\Installers\BaseInstaller->getInstallPath() at C:\server\core-installer-test\vendor\composer\installers\src\Composer\Installers\Installer.php:58
 Composer\Installers\Installer->getInstallPath() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Installer/LibraryInstaller.php:79
 Composer\Installer\LibraryInstaller->install() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Installer/InstallationManager.php:151
 Composer\Installer\InstallationManager->install() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Installer/InstallationManager.php:138
 Composer\Installer\InstallationManager->execute() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Installer.php:509
 Composer\Installer->doInstall() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Installer.php:210
 Composer\Installer->run() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Command/InstallCommand.php:97
 Composer\Command\InstallCommand->execute() at phar://C:/ProgramData/Composer/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
 Symfony\Component\Console\Command\Command->run() at phar://C:/ProgramData/Composer/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:897
 Symfony\Component\Console\Application->doRunCommand() at phar://C:/ProgramData/Composer/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:191
 Symfony\Component\Console\Application->doRun() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Console/Application.php:117
 Composer\Console\Application->doRun() at phar://C:/ProgramData/Composer/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:121
 Symfony\Component\Console\Application->run() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Console/Application.php:83
 Composer\Console\Application->run() at phar://C:/ProgramData/Composer/bin/composer.phar/bin/composer:43
 require() at C:\ProgramData\Composer\bin\composer.phar:15

wordpress-core-installer broken since last commit

a04c2c3#diff-b5d0ee8c97c7abd7e3fa29b9a27d1780

"^1.0" breaks composer.phar install

excerpt from vagrant composer.phar install

Writing /home/vagrant/.composer/cache/repo/https---packagist.org/provider-johnpbloch$wordpress-core-installer.json into cache
[RuntimeException]
Could not load package johnpbloch/wordpress-core-installer in http://packagist.org: [UnexpectedValueException] Could not parse version constraint ^1.0: Invalid version string "^1.0"

Prevent installing default themes/plugins

core should install wordpress core and leave all other theme/plugin to the composer.json Currently default themes/plugins are installing regardless of the themes/plugins list in composer.json

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.