{"id":261,"date":"2023-08-04T17:32:39","date_gmt":"2023-08-04T17:32:39","guid":{"rendered":"https:\/\/wp-yoda.com\/en\/?p=261"},"modified":"2023-10-29T16:07:17","modified_gmt":"2023-10-29T16:07:17","slug":"installing-wordpress-via-composer","status":"publish","type":"post","link":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/","title":{"rendered":"Install WordPress via Composer"},"content":{"rendered":"\n<p>In this article, we will talk about how to install WordPress via Composer. Let&#8217;s go through step by step how to do it. Let&#8217;s consider the options of installing WordPress in a separate directory and the classic option with a standard file structure.<\/p>\n\n\n\n<p><strong>There are a number of benefits to using Composer for your WordPress installation:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\" style=\"margin-top:var(--wp--preset--spacing--20);margin-right:var(--wp--preset--spacing--20);margin-bottom:var(--wp--preset--spacing--20);margin-left:var(--wp--preset--spacing--20)\">\n<li><strong>It&#8217;s convenient to update WordPress<\/strong><br>No more copying files if you have disabled WP update via the admin panel. To change the WordPress version, we only need to change the WordPress version number in the <code>composer.json<\/code> file and run the console command <code>composer install<\/code> .<\/li>\n\n\n\n<li><strong>Flexibility to change WordPress version<\/strong><br>Forget about upgrading to only the <code>latest<\/code> version of WordPress. With Composer, you can specify any version of WordPress you want, whether it&#8217;s a patch, minor or major version.<\/li>\n\n\n\n<li><strong>Simple Code Review<\/strong><br>Forget about thousands of lines of changes in PullRequest when you update WordPress. Your colleagues will only see the WordPress version change lines in <code>composer.json<\/code> and <code>composer.lock<\/code>.<\/li>\n\n\n\n<li><strong>WordPress core files will never be modified<\/strong><br>Core files, by accident or on purpose, can never be modified and committed into the GIT. WordPress will be installed via Composer. You will always be sure that a new version of WordPress was obtained from the official repository without modification.<\/li>\n\n\n\n<li><strong>Smaller repository size<\/strong><br>When using Composer, WordPress core files will not be stored in the repository. This will reduce the size of the repository, which will favorably affect repository cloning and deploys.<\/li>\n\n\n\n<li><strong>Using different versions of WordPress in a mono repository.<\/strong><br>Installing WordPress via Composer can help us with this too, but this solution is beyond the scope of this article.<\/li>\n<\/ul>\n\n\n\n<p>In order to start installing WP via Composer, you need to do some configuration of the project, which is described below.<\/p>\n\n\n  \r\n    \r\n<div id=\"wpj-jtoc\" class=\"wpj-jtoc wpj-jtoc--main --jtoc-the-content --jtoc-theme-basic-light --jtoc-title-align-left --jtoc-toggle-icon --jtoc-toggle-position-right --jtoc-toggle-1 --jtoc-has-numeration --jtoc-numeration-legacy --jtoc-has-custom-styles --jtoc-is-unfolded --jtoc-align-left\" >\r\n  <!-- TOC -->\r\n        <div class=\"wpj-jtoc--toc wpj-jtoc--toc-inline \" >\r\n              <div class=\"wpj-jtoc--header\">\r\n        <div class=\"wpj-jtoc--header-main\">\r\n                    <div class=\"wpj-jtoc--title\">\r\n                        <span class=\"wpj-jtoc--title-label\">Table of contents<\/span>\r\n          <\/div>\r\n                                <div class=\"wpj-jtoc--toggle-wrap\">\r\n                                                          <div class=\"wpj-jtoc--toggle-box\">\r\n                  <div class=\"wpj-jtoc--toggle\"><\/div>\r\n                <\/div>\r\n                          <\/div>\r\n                  <\/div>\r\n      <\/div>\r\n            <div class=\"wpj-jtoc--body\">\r\n            <nav class=\"wpj-jtoc--nav\">\r\n        <ol class=\"wpj-jtoc--items\"><li class=\"wpj-jtoc--item --jtoc-h2\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h2\" data-depth=\"2\">\r\n                                                <a href=\"#about-composer\"  title=\"About Composer\" data-numeration=\"1\">About Composer<\/a>\r\n                    <\/div><\/li><li class=\"wpj-jtoc--item --jtoc-h2\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h2\" data-depth=\"2\">\r\n                                                <a href=\"#install-wordpress-via-composer\"  title=\"Install WordPress via Composer\" data-numeration=\"2\">Install WordPress via Composer<\/a>\r\n                    <\/div><ol class=\"wpj-jtoc--items\"><li class=\"wpj-jtoc--item --jtoc-h3\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h3\" data-depth=\"3\">\r\n                                                <a href=\"#install-wordpress-with-a-classic-file-structure\"  title=\"Install WordPress with a classic file structure\" data-numeration=\"2.1\">Install WordPress with a classic file structure<\/a>\r\n                    <\/div><ol class=\"wpj-jtoc--items\"><li class=\"wpj-jtoc--item --jtoc-h4\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h4\" data-depth=\"4\">\r\n                                                <a href=\"#configuring-composerjson\"  title=\"Configuring composer.json\" data-numeration=\"2.1.1\">Configuring composer.json<\/a>\r\n                    <\/div><\/li><li class=\"wpj-jtoc--item --jtoc-h4\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h4\" data-depth=\"4\">\r\n                                                <a href=\"#setting-up-gitignore\"  title=\"Setting up .gitignore\" data-numeration=\"2.1.2\">Setting up .gitignore<\/a>\r\n                    <\/div><\/li><li class=\"wpj-jtoc--item --jtoc-h4\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h4\" data-depth=\"4\">\r\n                                                <a href=\"#source-code\"  title=\"Source code\" data-numeration=\"2.1.3\">Source code<\/a>\r\n                    <\/div><\/li><\/ol><\/li><li class=\"wpj-jtoc--item --jtoc-h3\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h3\" data-depth=\"3\">\r\n                                                <a href=\"#install-wordpress-in-a-separate-directory\"  title=\"Install WordPress in a separate directory\" data-numeration=\"2.2\">Install WordPress in a separate directory<\/a>\r\n                    <\/div><ol class=\"wpj-jtoc--items\"><li class=\"wpj-jtoc--item --jtoc-h4\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h4\" data-depth=\"4\">\r\n                                                <a href=\"#configuring-composerjson_1\"  title=\"Configuring composer.json\" data-numeration=\"2.2.1\">Configuring composer.json<\/a>\r\n                    <\/div><\/li><li class=\"wpj-jtoc--item --jtoc-h4\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h4\" data-depth=\"4\">\r\n                                                <a href=\"#configuring-gitignore\"  title=\"Configuring .gitignore\" data-numeration=\"2.2.2\">Configuring .gitignore<\/a>\r\n                    <\/div><\/li><li class=\"wpj-jtoc--item --jtoc-h4\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h4\" data-depth=\"4\">\r\n                                                <a href=\"#add-indexphp\"  title=\"Add index.php\" data-numeration=\"2.2.3\">Add index.php<\/a>\r\n                    <\/div><\/li><li class=\"wpj-jtoc--item --jtoc-h4\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h4\" data-depth=\"4\">\r\n                                                <a href=\"#add-the-wp-content-directory\"  title=\"Add the wp-content directory\" data-numeration=\"2.2.4\">Add the wp-content directory<\/a>\r\n                    <\/div><\/li><li class=\"wpj-jtoc--item --jtoc-h4\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h4\" data-depth=\"4\">\r\n                                                <a href=\"#lets-write-constants-with-urls-and-paths\"  title=\"Let\u2019s write constants with URLs and paths\" data-numeration=\"2.2.5\">Let\u2019s write constants with URLs and paths<\/a>\r\n                    <\/div><\/li><li class=\"wpj-jtoc--item --jtoc-h4\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h4\" data-depth=\"4\">\r\n                                                <a href=\"#source-code_1\"  title=\"Source code\" data-numeration=\"2.2.6\">Source code<\/a>\r\n                    <\/div><\/li><\/ol><\/li><\/ol><\/li><li class=\"wpj-jtoc--item --jtoc-h2\">\r\n        <div class=\"wpj-jtoc--item-content --jtoc-h2\" data-depth=\"2\">\r\n                                                <a href=\"#summarizing\"  title=\"Summarizing\" data-numeration=\"3\">Summarizing<\/a>\r\n                    <\/div><\/li><\/ol>      <\/nav>\r\n          <\/div>\r\n      <\/div>\r\n    <\/div>\r\n\n\n\n<h2 class=\"wp-block-heading\">About Composer<\/h2>\n\n\n\n<p>The <strong>Composer<\/strong> is a PHP dependency management tool. It allows you to declare the libraries your project depends on and will manage (install\/update) the dependencies instead of you. The Composer also provides proper solving of library dependency conflicts.<\/p>\n\n\n\n<p>For using Composer locally there are 2 options:<\/p>\n\n\n\n<ul class=\"wp-block-list\" style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">\n<li>Use the official documentation with the Composer binary installed locally <a href=\"https:\/\/getcomposer.org\/download\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/getcomposer.org\/download\/<\/a><br><em>(This option is preferred if you have not worked with Docker before)<\/em><\/li>\n\n\n\n<li>Work with the Composer by using a Docker Container (<em>following instructions <a href=\"https:\/\/github.com\/renakdup\/composer-with-wordpress\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">README.md<\/a><\/em>)<\/li>\n<\/ul>\n\n\n\n<p>Next, let&#8217;s talk about installing WordPress via Composer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install WordPress via Composer<\/h2>\n\n\n\n<p><strong>To install WordPress via Composer,<\/strong> we first need to create a <code>composer.json<\/code> file in the root of the project.<br>You can do this using the <code>composer init<\/code> command or create the file manually by pasting the example of code below into <code>composer.json<\/code>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; auto-links: false; title: ; notranslate\" title=\"\">\n{\n    &quot;name&quot;: &quot;wp-yoda\/composer-with-wordpress&quot;,\n    &quot;description&quot;: &quot;Example of using Composer for installing WordPress core and plugins&quot;,\n    &quot;require&quot;: {}\n}\n<\/pre><\/div>\n\n\n<p>Next, we need to add the <code>repositories<\/code> directive to <code>composer.json<\/code> .<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>What is the repositories directive in composer.json<\/p>\n<cite>A Repository in Composer is the source of the package. When installing packages, Composer will look in all repositories in the composer file to find the required package for the project.<br>By default, only the Packagist.org repository is registered in Composer. But you can add more repositories for your project by declaring them in the repositories directive of the <code>composer.json<\/code> file.<br><br>Read more about<em> Composer&#8217;s repository <a href=\"https:\/\/getcomposer.org\/doc\/05-repositories.md#repository\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">at the link<\/a><\/em><\/cite><\/blockquote>\n\n\n\n<p>The <code>composer.json<\/code> file will look like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; auto-links: false; title: ; notranslate\" title=\"\">\n{\n    &quot;name&quot;: &quot;wp-yoda\/composer-with-wordpress&quot;,\n    &quot;description&quot;: &quot;Example of using Composer for installing WordPress core and plugins&quot;,\n    &quot;repositories&quot;: &#x5B;\n        {\n            &quot;type&quot;: &quot;package&quot;,\n            &quot;package&quot;: {\n                &quot;name&quot;: &quot;wordpress\/wordpress&quot;,\n                &quot;version&quot;: &quot;6.2.2&quot;,\n                &quot;type&quot;: &quot;wordpress-core&quot;,\n                &quot;dist&quot;: {\n                    &quot;type&quot;: &quot;zip&quot;,\n                    &quot;url&quot;: &quot;https:\/\/github.com\/WordPress\/WordPress\/archive\/refs\/tags\/6.2.2.zip&quot;\n                }\n            }\n        }\n    ],\n    &quot;require&quot;: {}\n}\n<\/pre><\/div>\n\n\n<p>Now when you plug in the <code>wordpress\/wordpress<\/code> package. The composer will find the package in the added repository and install it.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-highlight-light-background-color has-background is-layout-flow wp-block-quote-is-layout-flow\">\n<p>There is no official WordPress package on packagist.org at this moment<\/p>\n<cite>It is not recommended to use unofficial WordPress packages like <code>johnpbloch\/wordpress<\/code> or <code>roots\/wordpress<\/code>. The authors&#8217; repositories can be hacked, code changed, package updated and the sites that use them will be infected.<br><strong>The most reliable way to install WordPress via Composer<\/strong> at the moment is the way described in the article &#8211; connecting the official WordPress GH repository to <code>composer.json<\/code>.<\/cite><\/blockquote>\n\n\n\n<p>Once we have added the source from where WordPress will be downloaded (the official repository), I suggest <strong>adding WordPress as a Composer dependency<\/strong>.<br>Let&#8217;s run the following command in the terminal:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncomposer require wordpress\/wordpress\n<\/pre><\/div>\n\n\n<p>The composer will plug the package <code>wordpress\/wordpress<\/code> into <code>composer.json<\/code> with this command and install it into our project in the <code>.\/vendor<\/code> directory.<br><br>You should see the following file structure:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><a href=\"https:\/\/wp-yoda.com\/wp-content\/uploads\/2023\/05\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wp-yoda.com\/wp-content\/uploads\/2023\/05\/image-4.png\" alt=\"Install WordPress via Composer\" class=\"wp-image-667\" width=\"307\" height=\"244\"\/><\/a><figcaption class=\"wp-element-caption\">inside the <strong>.\/vendor\/wordpress<\/strong> directory will be the core of WordPress<\/figcaption><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite>Remember to add <code>\/vendor\/<\/code> to the <code>.gitignore<\/code> file so that the <code>\/vendor<\/code> directory files are not indexed by GIT.<\/cite><\/blockquote>\n\n\n\n<p>Now our project has WordPress installed, but it is in the <code>vendor<\/code> directory, to make our project work it needs to be moved to another location. But where?<\/p>\n\n\n\n<p>There are 2 ways you can do this:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-d7d455e7 wp-block-columns-is-layout-flex\" style=\"padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><strong>The classic WordPress structure<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.\n\u251c\u2500\u2500 index.php\n\u251c\u2500\u2500 composer.json\n\u251c\u2500\u2500 composer.lock\n\u251c\u2500\u2500 vendor\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 autoload.php\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 ......\n\u251c\u2500\u2500 wp-admin\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 about.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 admin-ajax.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 admin-functions.php\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 ......\n\u251c\u2500\u2500 wp-content\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 mu-plugins\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 plugins\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 themes\/\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 uploads\/\n\u251c\u2500\u2500 wp-cron.php\n\u251c\u2500\u2500 wp-config.php\n\u251c\u2500\u2500 wp-includes\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 admin-bar.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 author-template.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 block-editor.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 block-i18n.json\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 block-patterns\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 block-patterns.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 block-supports\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 block-template-utils.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 block-template.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-db.php\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 ......\n\u251c\u2500\u2500 wp-links-opml.php\n\u251c\u2500\u2500 wp-load.php\n\u251c\u2500\u2500 wp-login.php\n\u251c\u2500\u2500 wp-mail.php\n\u251c\u2500\u2500 wp-settings.php\n\u251c\u2500\u2500 wp-signup.php\n\u251c\u2500\u2500 wp-trackback.php\n\u2514\u2500\u2500 xmlrpc.php\n<\/pre><\/div><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\">\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\"><strong>WordPress in a separate directory<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.\n\u251c\u2500\u2500 index.php\n\u251c\u2500\u2500 composer.json\n\u251c\u2500\u2500 composer.lock\n\u251c\u2500\u2500 vendor\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 autoload.php\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 .....\n\u251c\u2500\u2500 wp\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 index.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-activate.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-admin\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-blog-header.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-comments-post.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-config-sample.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-cron.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-includes\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-links-opml.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-load.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-login.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-mail.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-settings.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-signup.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-trackback.php\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 xmlrpc.php\n\u251c\u2500\u2500 wp-config.php\n\u2514\u2500\u2500 wp-content\/\n    \u251c\u2500\u2500 mu-plugins\/\n    \u251c\u2500\u2500 plugins\/\n    \u251c\u2500\u2500 themes\/\n    \u2514\u2500\u2500 uploads\/\n\n<\/pre><\/div><\/div>\n<\/div>\n\n\n\n<p>You&#8217;ll know which approach will suit you better when you read about both options in the article.<br>First, let&#8217;s look at <strong>installing WordPress via Composer with a classic file structure<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install WordPress with a classic file structure<\/h3>\n\n\n\n<p><strong><strong>The classic WordPress structure<\/strong> of a project<\/strong> &#8211; is a variant where we place all WordPress core files in the root of the project, along with the project files. There is no separation between the WP core and the code we write.<br>This option has its own advantages and disadvantages.<br><br><strong>Advantages<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\" style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">\n<li>All plugins are compatible with this project structure as it comes out of the box.<\/li>\n\n\n\n<li>It requires no additional configuration of directory and URL constants.<\/li>\n\n\n\n<li>You can implement it with an existing project without fear of breaking something. Since the structure of files and directories is not changed.<\/li>\n<\/ul>\n\n\n\n<p><strong>Disadvantages<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\" style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">\n<li>The WordPress core files are mixed with the project files, which makes it difficult to work with the project.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Configuring composer.json<\/h4>\n\n\n\n<p>To move the directory from <code>vendor<\/code> to the root directory of the project we will use <strong>Composer Script events<\/strong>.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite><strong>Composer scripts events<\/strong> are Composer events that run custom commands before\/after Composer commands are executed. For example you can run a command after <code>composer install<\/code>.<br><br><em>You can read more <a href=\"https:\/\/getcomposer.org\/doc\/articles\/scripts.md#what-is-a-script-\" target=\"_blank\" rel=\"noreferrer noopener\">at the link<\/a>.<\/em><\/cite><\/blockquote>\n\n\n\n<p>Add <code>scripts<\/code> directive to <code>composer.json<\/code> with <code>post-install-cmd<\/code> event that fires after <code>composer install<\/code>.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n    &quot;scripts&quot;: {\n        &quot;post-install-cmd&quot;: &quot;cp -r .\/vendor\/wordpress\/wordpress\/* .\/&quot;\n    }\n<\/pre><\/div>\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite>In the <code>\"post-install-cmd\"<\/code> event, we copy the contents of the installed WordPress from <code>vendor<\/code> directory to our working directory <code>.\/<\/code><\/cite><\/blockquote>\n\n\n\n<p>Now run the command in the terminal:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncomposer install\n<\/pre><\/div>\n\n\n<p>After that, we can see the WordPress files in our project. Now let&#8217;s add the core files to <code>.gitignore<\/code> to keep them out of the repository and see in the GIT index only our project files.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Setting up .gitignore<\/h4>\n\n\n\n<p>To keep core files out of the GIT index, you should add the following rules to <code>.gitignore<\/code><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.idea\n\/vendor\/\n\n# ignore WordPress files\n\/index.php\n\/license.txt\n\/readme.html\n\/wp-activate.php\n\/wp-blog-header.php\n\/wp-comments-post.php\n\/wp-config-sample.php\n\/wp-config.php\n\/wp-cron.php\n\/wp-links-opml.php\n\/wp-load.php\n\/wp-login.php\n\/wp-mail.php\n\/wp-settings.php\n\/wp-signup.php\n\/wp-trackback.php\n\/xmlrpc.php\n\n\/wp-includes\n\/wp-admin\n\n\/wp-content\/*\n!\/wp-content\n\n\/wp-content\/plugins\/*\n!\/wp-content\/plugins\/\n!\/wp-content\/plugins\/YourCustomPluginName\n\n\/wp-content\/themes\/*\n!\/wp-content\/themes\/\n!\/wp-content\/themes\/YourCutsomTheme\n\n<\/pre><\/div>\n\n\n<p>Now the core files will not be indexed.<br><br>In order to add a new plugin or theme to the repository, you need to add lines to the end of the <code>.gitignore<\/code> file to exclude new themes or plugins from being ignored by example:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# new plugin\n!\/wp-content\/plugins\/YourCustomPluginName\n\n# new theme\n!\/wp-content\/themes\/YourCutsomTheme\n<\/pre><\/div>\n\n\n<p>Where <code>YourCustomPluginName<\/code> or <code>YourCustomTheme<\/code> is the directory name of your WP plugin or theme.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Source code<\/h4>\n\n\n\n<p>The source code of the WordPress installation with the classic structure is available <a href=\"https:\/\/github.com\/renakdup\/classic-Installation-wordpress-via-composer\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">via a link on GitHub<\/a>. You can deploy it locally by following the instructions in <code>README.md<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install WordPress in a separate directory<\/h3>\n\n\n\n<p><strong>Installing WordPress in a separate directory<\/strong> is a variant of installing WordPress via Composer where we place all the core files in a separate directory, away from the project files.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.\n\u251c\u2500\u2500 index.php\n\u251c\u2500\u2500 composer.json\n\u251c\u2500\u2500 composer.lock\n\u251c\u2500\u2500 vendor\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 autoload.php\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 .....\n\u251c\u2500\u2500 wp\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-activate.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-admin\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-blog-header.php\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-includes\/\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 wp-load.php\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 .....\n\u251c\u2500\u2500 wp-config.php\n\u2514\u2500\u2500 wp-content\/\n    \u251c\u2500\u2500 mu-plugins\/\n    \u251c\u2500\u2500 plugins\/\n    \u251c\u2500\u2500 themes\/\n    \u2514\u2500\u2500 uploads\/\n\n<\/pre><\/div>\n\n\n<p>This option has its advantages and disadvantages. Let&#8217;s talk about them.<\/p>\n\n\n\n<p><strong>Advantages<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\" style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">\n<li>Convenient code structure, nothing gets in the way and does not distract you from development. You work only with the <code>.\/wp-content<\/code> directory, themes, and plugins, the core files do not distract you when working, because they are hidden in the <code>.\/wp<\/code> directory.<\/li>\n\n\n\n<li>In case the WP core is stored in a separate directory, updating it is less painful as you only need to replace the core files in the <code>.\/wp<\/code> directory. There is no chance to overwrite project files (Themes, Plugins) with kernel files.<\/li>\n<\/ul>\n\n\n\n<p><strong>Disadvantages<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\" style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">\n<li>Some plugins that are &#8220;not written according to WP standards&#8221; may not work due to hard-coded paths relying on the &#8220;classic project structure&#8221;.<\/li>\n\n\n\n<li>You need to configure constants <code>wp-config.php<\/code> in WordPress, to get WordPress URLs and paths to the correct directories.<\/li>\n\n\n\n<li>You need to add the <code>index.php<\/code> file to the root of the project.<\/li>\n<\/ul>\n\n\n\n<p>Let&#8217;s move on to configuring composer.json.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Configuring composer.json<\/h4>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite>What are <strong>Composer Scripts<\/strong> &#8211; I described in the <strong>classic WordPress installation variant<\/strong> in this article.<\/cite><\/blockquote>\n\n\n\n<p>To use this option, you need to add the <code>scripts<\/code> directive with a <code>post-install-cmd<\/code> event that fires after <code>install<\/code>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n    &quot;scripts&quot;: {\n        &quot;post-install-cmd&quot;: &quot;mkdir -p .\/wp &amp;&amp; cp -r .\/vendor\/wordpress\/wordpress\/* .\/wp&quot;\n    }\n<\/pre><\/div>\n\n\n<p>In the script <code>\"post-install-cmd\"<\/code> we copy the contents of the installed WordPress from the <code>vendor<\/code> directory to the <code>.\/wp<\/code> directory. The WordPress core will be stored in the <code>.\/wp<\/code> directory.<\/p>\n\n\n\n<p>Now we can perform a WordPress installation through Composer:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncomposer install\n<\/pre><\/div>\n\n\n<p>and you&#8217;ll see a <code>.\/wp<\/code> directory in the root of your project with the WordPress core.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Configuring .gitignore<\/h4>\n\n\n\n<p>To keep kernel files out of the GIT index, you should add the following rules to <code>.gitignore<\/code><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.idea\n\/vendor\/\n\n# ignore WordPress files\n\/wp\n\n\/wp-content\/*\n!\/wp-content\n!\/wp-content\/index.php\n\n!\/wp-content\/mu-plugins\/\n!\/wp-content\/plugins\/\n!\/wp-content\/themes\/\n<\/pre><\/div>\n\n\n<p>After adding these lines, <em>WordPress core<\/em>, <em>cache<\/em> in <em>wp-content<\/em>, <em>uploads<\/em> and other WordPress system files will not be indexed.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite>If you want to add a file or directory from wp-content to the GIT index, simply exclude that directory from <code>.gitignore<\/code> with a <code>!<\/code> sign in front of that directory: <code>!\/wp-content\/new-directory\/<\/code> <\/cite><\/blockquote>\n\n\n\n<p>Let&#8217;s go to add an <code>index.php<\/code>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Add index.php<\/h4>\n\n\n\n<p>Since our core is in the <code>wp<\/code> directory, we do not have an <code>index.php<\/code> file in the root of the project. Hence WP core will not be loaded for client requests. Because of the absence of the <code>index.php<\/code> main file. <br>Let&#8217;s create the <code>index.php<\/code> file and add the following code to it:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\ndefine( &#039;WP_USE_THEMES&#039;, true );\n\n\/** Loads the WordPress Environment and Template *\/\nrequire __DIR__ . &#039;\/wp\/wp-blog-header.php&#039;;\n<\/pre><\/div>\n\n\n<p>This standard <code>index.php<\/code> file from WP with one exception, we changed the path to the file <code>wp-blog-header.php<\/code>  to the file into the <code>wp<\/code> directory.<\/p>\n\n\n\n<p>Let&#8217;s move on to creating the <code>wp-content\/<\/code> directory and customizing it.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Add the wp-content directory<\/h4>\n\n\n\n<p>The WordPress core is located in the directory <code>.\/wp<\/code>, and developed themes and plugins will be located inside <code>.\/wp-content<\/code>.<br>For this structure we need to create a directory <code>.\/wp-content<\/code> in the root of the project, with the following contents.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.\n\u251c\u2500\u2500 wp\/\n\u2514\u2500\u2500 wp-content\/\n  \u00a0\u00a0 \u251c\u2500\u2500 index.php\n  \u00a0\u00a0 \u251c\u2500\u2500 mu-plugins\/\n  \u00a0\u00a0 \u251c\u2500\u2500 plugins\/\n  \u00a0\u00a0 \u251c\u2500\u2500 themes\/\n  \u00a0\u00a0 \u2514\u2500\u2500 uploads\/\n<\/pre><\/div>\n\n\n<p>You can copy <code>wp-content<\/code> from the <code>.\/wp<\/code> directory and paste it into the root of your project, deleting all the unnecessary stuff.<br>Now you can add the plugins and themes you need to <code>.\/wp-content\/themes<\/code> or <code>.\/wp-content\/plugins<\/code> .<\/p>\n\n\n\n<p>After adding the <code>wp-content<\/code> directory, we need to set the correct constants for WordPress.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Let&#8217;s write constants with URLs and paths<\/h4>\n\n\n\n<p>In order for WordPress to understand what URLs and paths the WordPress core and <code>wp-content<\/code> directory are located at we need to set constants with the correct values.<\/p>\n\n\n\n<p>But before that, we need to create a <code>wp-config.php<\/code> file in the project root.<br>To do this, we can copy <code>wp-config.php<\/code> from <code>.\/wp\/<\/code> to the project root with the name <code>wp-config.php<\/code> .<\/p>\n\n\n\n<p>Once <code>wp-config.php<\/code> is created, add the following constants to the end of the <code>wp-config.php<\/code> file, but before the line <code>require_once <em>ABSPATH <\/em>. 'wp-settings.php';<\/code> <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; auto-links: false; title: ; notranslate\" title=\"\">\ndefine( &#039;WP_HOME&#039;, &#039;http:\/\/&#039; . $_SERVER&#x5B;&#039;HTTP_HOST&#039;] ); \/\/ Site URL for the front-of-site\ndefine( &#039;WP_SITEURL&#039;, &#039;http:\/\/&#039; . $_SERVER&#x5B;&#039;HTTP_HOST&#039;] . &#039;\/wp&#039; ); \/\/ URL address with WP core (which is for the admin)\n\ndefine( &#039;WP_CONTENT_DIR&#039;, __DIR__ . &#039;\/wp-content&#039; );\ndefine( &#039;WP_CONTENT_URL&#039;, WP_HOME . &#039;\/wp-content&#039; );\n<\/pre><\/div>\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite><code>WP_SITEURL<\/code> and <code>WP_HOME<\/code> override the value of <code>siteurl<\/code> and <code>home<\/code> option in the <code>wp_options<\/code> table respectively. But they do not change these values in the database.<br><br>* <code>siteurl<\/code>&nbsp;&#8211; is the URL where the WordPress core is located.<br>* <code>home<\/code>&nbsp;&#8211; is the URL of the site (front-end).<br><br><em>You can read more at wp-kama <a href=\"https:\/\/wp-kama.ru\/handbook\/codex\/wp-config-php#wp_siteurl\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">at this link<\/a><\/em><\/cite><\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite>The <code>WP_CONTENT_DIR<\/code> and <code>WP_CONTENT_URL<\/code> consts are needed to specify the path to the <code>.\/wp-content<\/code> directory in our project, since WordPress core has been placed in the <code>.\/wp<\/code> . <br>If we don&#8217;t specify these constants, WP will look for wp-content in the <code>.\/wp<\/code> directory.<\/cite><\/blockquote>\n\n\n\n<p>When you go to the site you should see the following error<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/wp-yoda.com\/wp-content\/uploads\/2023\/08\/image-2-1024x287.png\" alt=\"Install WordPress via Composer\" class=\"wp-image-1594\"\/><\/figure>\n\n\n\n<p>This will mean that you need to fill database connection constants in <code>wp-config.php<\/code>. Once you have filled this in, go to the admin panel and activate the added theme in the admin area.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-highlight-light-background-color has-background is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite>The admin panel is available at <code>\/wp\/wp-admin<\/code><\/cite><\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\">Source code<\/h4>\n\n\n\n<p>The full code for <strong>Installing WordPress in a separate directory<\/strong> is available in the repository via <a href=\"https:\/\/github.com\/renakdup\/installing-wordpress-in-separate-directory-via-composer\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">the link on GitHub<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summarizing<\/h2>\n\n\n\n<p>Which option is more suitable is of course up to you. If you have a well-established project that has been developing for many years, and you are not the developer who has been running it since its inception, then I would not recommend you to switch to the &#8220;Install WordPress via Composer in a separate directory&#8221; option. It&#8217;s better to consider the &#8220;Install WordPress with Classic File Structure&#8221; option. In this case, you have no risk of breaking anything.<br>While the option of &#8220;<strong>Install WP via Composer in a separate directory<\/strong>&#8221; is more suitable for new projects. With it, you will be able to limit a more convenient file structure of the project without fear of breaking it.<\/p>\n\n\n\n<p>Don&#8217;t hesitate to tell your colleagues about this approach and apply it to projects.<\/p>\n\n\n\n<p>This is the first article in a series of two articles <a href=\"https:\/\/wp-yoda.com\/tag\/ispolzovanie-composer-with-wordpress\/\" target=\"_blank\" rel=\"noreferrer noopener\">Using Composer in WordPress<\/a>.<br>The second article about installing plugins via WordPress will be published a bit later.<\/p>\n\n\n\n<p><br><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will talk about how to install WordPress via Composer. Let&#8217;s go through step by step how to do it. Let&#8217;s consider the options of installing WordPress in a separate directory and the classic option with a standard file structure.<\/p>\n","protected":false},"author":1,"featured_media":424,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,23,7],"tags":[25,26,8],"class_list":["post-261","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-composer","category-tooling","category-wordpress","tag-composer","tag-using-composer-with-wordpress","tag-wordpress"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Install WordPress via Composer - WP Yoda<\/title>\n<meta name=\"description\" content=\"In this article, we will talk about how to install WordPress via Composer. Let&#039;s go through step by step how to do it. Let&#039;s consider the options of installing WordPress in a separate directory and the classic option with a standard file structure.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Install WordPress via Composer - WP Yoda\" \/>\n<meta property=\"og:description\" content=\"In this article, we will talk about how to install WordPress via Composer. Let&#039;s go through step by step how to do it. Let&#039;s consider the options of installing WordPress in a separate directory and the classic option with a standard file structure.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Yoda\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-04T17:32:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-29T16:07:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wp-yoda.com\/en\/wp-content\/uploads\/sites\/2\/2023\/08\/Component-1-2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1455\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"\u0410\u043d\u0434\u0440\u0435\u0439 \u041f\u0438\u0441\u0430\u0440\u0435\u0432\u0441\u043a\u0438\u0439\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u0410\u043d\u0434\u0440\u0435\u0439 \u041f\u0438\u0441\u0430\u0440\u0435\u0432\u0441\u043a\u0438\u0439\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wordpress\\\/installing-wordpress-via-composer\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wordpress\\\/installing-wordpress-via-composer\\\/\"},\"author\":{\"name\":\"\u0410\u043d\u0434\u0440\u0435\u0439 \u041f\u0438\u0441\u0430\u0440\u0435\u0432\u0441\u043a\u0438\u0439\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#\\\/schema\\\/person\\\/195c797aee113d174e07e4887a9fe464\"},\"headline\":\"Install WordPress via Composer\",\"datePublished\":\"2023-08-04T17:32:39+00:00\",\"dateModified\":\"2023-10-29T16:07:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wordpress\\\/installing-wordpress-via-composer\\\/\"},\"wordCount\":2044,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wordpress\\\/installing-wordpress-via-composer\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/08\\\/Component-1-2.png\",\"keywords\":[\"Composer\",\"Using Composer with WordPress\",\"WordPress\"],\"articleSection\":[\"Composer\",\"Tooling\",\"WordPress\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wordpress\\\/installing-wordpress-via-composer\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wordpress\\\/installing-wordpress-via-composer\\\/\",\"url\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wordpress\\\/installing-wordpress-via-composer\\\/\",\"name\":\"Install WordPress via Composer - WP Yoda\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wordpress\\\/installing-wordpress-via-composer\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wordpress\\\/installing-wordpress-via-composer\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/08\\\/Component-1-2.png\",\"datePublished\":\"2023-08-04T17:32:39+00:00\",\"dateModified\":\"2023-10-29T16:07:17+00:00\",\"description\":\"In this article, we will talk about how to install WordPress via Composer. Let's go through step by step how to do it. Let's consider the options of installing WordPress in a separate directory and the classic option with a standard file structure.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wordpress\\\/installing-wordpress-via-composer\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wordpress\\\/installing-wordpress-via-composer\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wordpress\\\/installing-wordpress-via-composer\\\/#primaryimage\",\"url\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/08\\\/Component-1-2.png\",\"contentUrl\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/08\\\/Component-1-2.png\",\"width\":1455,\"height\":720,\"caption\":\"Install WordPress via Composer\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wordpress\\\/installing-wordpress-via-composer\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Install WordPress via Composer\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/\",\"name\":\"WP Yoda\",\"description\":\"Notes about PHP, WordPress and IT\",\"publisher\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#organization\",\"name\":\"WP Yoda\",\"url\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/05\\\/Andrew_222_Master_Yoda__WordPress_plain_background_763a84a4-5042-4fac-9bdb-4562c05563e7.png\",\"contentUrl\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/05\\\/Andrew_222_Master_Yoda__WordPress_plain_background_763a84a4-5042-4fac-9bdb-4562c05563e7.png\",\"width\":1024,\"height\":1024,\"caption\":\"WP Yoda\"},\"image\":{\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/#\\\/schema\\\/person\\\/195c797aee113d174e07e4887a9fe464\",\"name\":\"\u0410\u043d\u0434\u0440\u0435\u0439 \u041f\u0438\u0441\u0430\u0440\u0435\u0432\u0441\u043a\u0438\u0439\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d3f11053e005f02e0dc3049c010b45034646963c7af8edac8076c3767022d750?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d3f11053e005f02e0dc3049c010b45034646963c7af8edac8076c3767022d750?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d3f11053e005f02e0dc3049c010b45034646963c7af8edac8076c3767022d750?s=96&r=g\",\"caption\":\"\u0410\u043d\u0434\u0440\u0435\u0439 \u041f\u0438\u0441\u0430\u0440\u0435\u0432\u0441\u043a\u0438\u0439\"},\"sameAs\":[\"https:\\\/\\\/wp-yoda.com\"],\"url\":\"https:\\\/\\\/wp-yoda.com\\\/en\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Install WordPress via Composer - WP Yoda","description":"In this article, we will talk about how to install WordPress via Composer. Let's go through step by step how to do it. Let's consider the options of installing WordPress in a separate directory and the classic option with a standard file structure.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/","og_locale":"en_US","og_type":"article","og_title":"Install WordPress via Composer - WP Yoda","og_description":"In this article, we will talk about how to install WordPress via Composer. Let's go through step by step how to do it. Let's consider the options of installing WordPress in a separate directory and the classic option with a standard file structure.","og_url":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/","og_site_name":"WP Yoda","article_published_time":"2023-08-04T17:32:39+00:00","article_modified_time":"2023-10-29T16:07:17+00:00","og_image":[{"width":1455,"height":720,"url":"https:\/\/wp-yoda.com\/en\/wp-content\/uploads\/sites\/2\/2023\/08\/Component-1-2.png","type":"image\/png"}],"author":"\u0410\u043d\u0434\u0440\u0435\u0439 \u041f\u0438\u0441\u0430\u0440\u0435\u0432\u0441\u043a\u0438\u0439","twitter_card":"summary_large_image","twitter_misc":{"Written by":"\u0410\u043d\u0434\u0440\u0435\u0439 \u041f\u0438\u0441\u0430\u0440\u0435\u0432\u0441\u043a\u0438\u0439","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/#article","isPartOf":{"@id":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/"},"author":{"name":"\u0410\u043d\u0434\u0440\u0435\u0439 \u041f\u0438\u0441\u0430\u0440\u0435\u0432\u0441\u043a\u0438\u0439","@id":"https:\/\/wp-yoda.com\/en\/#\/schema\/person\/195c797aee113d174e07e4887a9fe464"},"headline":"Install WordPress via Composer","datePublished":"2023-08-04T17:32:39+00:00","dateModified":"2023-10-29T16:07:17+00:00","mainEntityOfPage":{"@id":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/"},"wordCount":2044,"commentCount":0,"publisher":{"@id":"https:\/\/wp-yoda.com\/en\/#organization"},"image":{"@id":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/#primaryimage"},"thumbnailUrl":"https:\/\/wp-yoda.com\/en\/wp-content\/uploads\/sites\/2\/2023\/08\/Component-1-2.png","keywords":["Composer","Using Composer with WordPress","WordPress"],"articleSection":["Composer","Tooling","WordPress"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/","url":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/","name":"Install WordPress via Composer - WP Yoda","isPartOf":{"@id":"https:\/\/wp-yoda.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/#primaryimage"},"image":{"@id":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/#primaryimage"},"thumbnailUrl":"https:\/\/wp-yoda.com\/en\/wp-content\/uploads\/sites\/2\/2023\/08\/Component-1-2.png","datePublished":"2023-08-04T17:32:39+00:00","dateModified":"2023-10-29T16:07:17+00:00","description":"In this article, we will talk about how to install WordPress via Composer. Let's go through step by step how to do it. Let's consider the options of installing WordPress in a separate directory and the classic option with a standard file structure.","breadcrumb":{"@id":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/#primaryimage","url":"https:\/\/wp-yoda.com\/en\/wp-content\/uploads\/sites\/2\/2023\/08\/Component-1-2.png","contentUrl":"https:\/\/wp-yoda.com\/en\/wp-content\/uploads\/sites\/2\/2023\/08\/Component-1-2.png","width":1455,"height":720,"caption":"Install WordPress via Composer"},{"@type":"BreadcrumbList","@id":"https:\/\/wp-yoda.com\/en\/wordpress\/installing-wordpress-via-composer\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wp-yoda.com\/en\/"},{"@type":"ListItem","position":2,"name":"Install WordPress via Composer"}]},{"@type":"WebSite","@id":"https:\/\/wp-yoda.com\/en\/#website","url":"https:\/\/wp-yoda.com\/en\/","name":"WP Yoda","description":"Notes about PHP, WordPress and IT","publisher":{"@id":"https:\/\/wp-yoda.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wp-yoda.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/wp-yoda.com\/en\/#organization","name":"WP Yoda","url":"https:\/\/wp-yoda.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-yoda.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/wp-yoda.com\/en\/wp-content\/uploads\/sites\/2\/2023\/05\/Andrew_222_Master_Yoda__WordPress_plain_background_763a84a4-5042-4fac-9bdb-4562c05563e7.png","contentUrl":"https:\/\/wp-yoda.com\/en\/wp-content\/uploads\/sites\/2\/2023\/05\/Andrew_222_Master_Yoda__WordPress_plain_background_763a84a4-5042-4fac-9bdb-4562c05563e7.png","width":1024,"height":1024,"caption":"WP Yoda"},"image":{"@id":"https:\/\/wp-yoda.com\/en\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/wp-yoda.com\/en\/#\/schema\/person\/195c797aee113d174e07e4887a9fe464","name":"\u0410\u043d\u0434\u0440\u0435\u0439 \u041f\u0438\u0441\u0430\u0440\u0435\u0432\u0441\u043a\u0438\u0439","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d3f11053e005f02e0dc3049c010b45034646963c7af8edac8076c3767022d750?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d3f11053e005f02e0dc3049c010b45034646963c7af8edac8076c3767022d750?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d3f11053e005f02e0dc3049c010b45034646963c7af8edac8076c3767022d750?s=96&r=g","caption":"\u0410\u043d\u0434\u0440\u0435\u0439 \u041f\u0438\u0441\u0430\u0440\u0435\u0432\u0441\u043a\u0438\u0439"},"sameAs":["https:\/\/wp-yoda.com"],"url":"https:\/\/wp-yoda.com\/en\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/posts\/261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/comments?post=261"}],"version-history":[{"count":0,"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/posts\/261\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/media\/424"}],"wp:attachment":[{"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/media?parent=261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/categories?post=261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp-yoda.com\/en\/wp-json\/wp\/v2\/tags?post=261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}