SlideShare a Scribd company logo
Using Composer to create
manageable WordPress websites
Anna Ladoshkina
WordCamp Europe, 24/06/2016
I’ve been making websites for NGOs for 7 years
@foralien bureau / Teplitsa. Technologies for social good
You may need it if…
You are developing websites on PHP (with WordPress)
You would like to use modern development tool
You would like to have more organized projects
You would like to start easily
You hear that buzzword all the time, but…
Using Composer to create manageable WordPress websites
What’s dependency?
Suppose:
You have a project that depends on a number of libraries.
Some of those libraries depend on other libraries.
Composer:
Enables you to declare the libraries you depend on.
Finds out versions of packages and installs them (into your project)
Using Composer to create manageable WordPress websites
How to install?
PHP 5.3.x and command line
Follow instruction at
https://getcomposer.org/doc/00-intro.md
Add composer.json to the project folder
Composer.json?
$ composer init
{
"name": "foralien/my_pack",
"description": "Test package",
"authors": [
{
"name": "Anna Ladoshkina",
"email": "webdev@foralien.com"
}
],
"require": {}
}
Where to find packages?
Composer-specific repositories
https://packagist.org/
GitHub (other open-source repositories)
https://github.com/
Create yourself
author/package_name
packagist.org
Add them one by one…
$ composer config repositories.foo vcs
https://github.com/foo/bar
$ composer require package
More on command-line interface: https://getcomposer.org/doc/03-cli.md
…or specify them all in composer.json
"repositories": [
{
"type": "composer",
"url" : "http://some-packagist.org"
},
{
"type": "vcs",
"url": "https://github.com/username/repo"
},
{
"type": "artifact",
"url": "local_folder/"
}
],
"require" : {
"author/package": "1.0",
"another_author/package" : "4.4"
}
More on composer.json schema: https://getcomposer.org/doc/04-schema.md
$ composer install
Have some coffee and
check /vendor folder
Even for WordPress?
What’s the problem?
Common WordPress website project
- core files
- wp-config.php
- wp-content/plugins
- wp-content/themes
- wp-content/languages
- wp-content/uploads
A few questions to ask
What should be under version control?
- What are dependencies?
- Where are Composer-compatible repositories?
- What to do with vendor folder?
Give me an example
https://roots.io/
Bedrock - WordPress boilerplate
http://composer.rarst.net
Unofficial companion to Composer documentation
for WordPress developers
Step by step
Core is dependency
plugins
languages
themes
What are dependencies?
Tune project structure
WordPress in subfolder
https://codex.wordpress.org/
Giving_WordPress_Its_Own_Directory
Move wp-content folder
https://codex.wordpress.org/
Editing_wp-config.php#Moving_wp-
content_folder
In settings
In wp-config.php
define( 'WP_CONTENT_DIR',
dirname(__FILE__) . '/wp-content' );
define( 'WP_CONTENT_URL',
'//domain.com/wp-content' );
WordPress specific
repositories
core
plugins
languages
Where are Composer-compatible repositories?
WordPress core at https://packagist.org/
Plugins at wpackagist.org
Language-packs at wp-languages.github.io
Local folder /artifacts
myproject/myplugin-2.0.zip
— plugins code
— composer.json
Add them into composer.json
"repositories": [
{
"type": "composer",
"url" : "http://wpackagist.org"
},
{
"type": "composer",
"url": "http://wp-languages.github.io"
},
]
Config custom paths
for dependencies
core
plugins
languages
What to do with vendor folder?
Paths in composer.json
"config" : {
"vendor-dir": "wp-content/vendor",
},
"extra" : {
"wordpress-install-dir": "core",
"dropin-paths": {
"wp-content/languages/":
["vendor:koodimonni-language"]
}
}
Finally add dependencies into…
…require or requires-dev sections
"require" : {
"composer/installers" : "~1.0",
"johnpbloch/wordpress" : ">=4.4",
"wpackagist-plugin/wordpress-seo" : "@stable",
"koodimonni-language/core-ru_ru" : "*" ,
"myproject/myplugin" : "2.0",
},
"require-dev" : {
"wpackagist-plugin/menu-exporter" : "@stable",
"wpackagist-plugin/wordpress-importer" : "@stable"
}
$ composer install
composer.lock
$ composer update
@foralien bureau / foralien.com
Thank you
Anna Ladoshkina
www.facebook.com/anna.ladoshkina
webdev@foralien.com

More Related Content

PPTX
The Ultimate WordPress Development Environment
PDF
Building a community of Open Source intranet users
PDF
GlotPress aka translate.wordpress.org
PDF
WordPress as a Headless CMS - Bronson Quick
PDF
WordPress 4.4 and Beyond
PDF
Unscrambling An Omelette - How Companies Can Use WordPress Better - Jeremy Ke...
PDF
Make web as webapp
PDF
The Future of-the CMS (Twin Cities DrupalCamp 2015)
The Ultimate WordPress Development Environment
Building a community of Open Source intranet users
GlotPress aka translate.wordpress.org
WordPress as a Headless CMS - Bronson Quick
WordPress 4.4 and Beyond
Unscrambling An Omelette - How Companies Can Use WordPress Better - Jeremy Ke...
Make web as webapp
The Future of-the CMS (Twin Cities DrupalCamp 2015)

What's hot (20)

PDF
My Contributor Story
PDF
Developing FirefoxOS
PDF
It Takes a Village to Make WordPress
PDF
Coding with jetpack
PPTX
Blazor - .NET in the Browser!
PPTX
WordPress Coding Standards
PPTX
WordPress Development with VVV, VV, and Vagrant
PDF
Composer - The missing package manager for PHP
PPTX
Welcome to the World of WordPress
PDF
Introducing WordPress Multitenancy (Wordcamp Vegas/Orlando 2015/WPCampus)
PDF
Trying Out Tomorrow’s WordPress Today
PPTX
PDF
Get Started in Professional WordPress Design & Development
PPTX
DevDay 2018 - Blazor
PPTX
Building a resposive slider plugin for WordPress theme
PDF
WordPress: Getting Under the Hood
PDF
WordPress Developer tools
PDF
Introducing Wordpress Multitenancy
PPTX
Introduction to Web Technology Stacks
PPTX
Better WordPress Theme Development Workflow
My Contributor Story
Developing FirefoxOS
It Takes a Village to Make WordPress
Coding with jetpack
Blazor - .NET in the Browser!
WordPress Coding Standards
WordPress Development with VVV, VV, and Vagrant
Composer - The missing package manager for PHP
Welcome to the World of WordPress
Introducing WordPress Multitenancy (Wordcamp Vegas/Orlando 2015/WPCampus)
Trying Out Tomorrow’s WordPress Today
Get Started in Professional WordPress Design & Development
DevDay 2018 - Blazor
Building a resposive slider plugin for WordPress theme
WordPress: Getting Under the Hood
WordPress Developer tools
Introducing Wordpress Multitenancy
Introduction to Web Technology Stacks
Better WordPress Theme Development Workflow
Ad

Viewers also liked (20)

PDF
Практическая доступность с WordPress
PDF
Composer и разработка сайтов на WordPress
PDF
Ведение бизнеса на основе WordPress
PDF
Managing a Local WordPress Community, WordCamp Europe 2016
PDF
Аудит сайта некоммерческой организации
PDF
Сайт городского проекта: что делает его востребованным
PDF
Краудфандинговая кампания - с какого конца начать?
PDF
WordPress: SEO. Ловим на живца.
PDF
Looking into WordPress Core, WordCamp Russia 2015
PDF
Everything You Need to Know About WP_Query, WordCamp Russia 2014
ODP
Contributing to WordPress, WordCamp Russia 2013
PDF
WordPress-обновления
PDF
Моделирование контента в WordPress
PDF
WordPress и Яндекс.Новости
PPT
An Introduction to AngularJs Unittesting
PDF
Grunt js and WordPress
PDF
Mastering Grunt
PDF
GruntJS + Wordpress
PDF
Angular js, Yeomon & Grunt
ODP
Wrangling the WordPress Template Hierarchy Like a Boss
Практическая доступность с WordPress
Composer и разработка сайтов на WordPress
Ведение бизнеса на основе WordPress
Managing a Local WordPress Community, WordCamp Europe 2016
Аудит сайта некоммерческой организации
Сайт городского проекта: что делает его востребованным
Краудфандинговая кампания - с какого конца начать?
WordPress: SEO. Ловим на живца.
Looking into WordPress Core, WordCamp Russia 2015
Everything You Need to Know About WP_Query, WordCamp Russia 2014
Contributing to WordPress, WordCamp Russia 2013
WordPress-обновления
Моделирование контента в WordPress
WordPress и Яндекс.Новости
An Introduction to AngularJs Unittesting
Grunt js and WordPress
Mastering Grunt
GruntJS + Wordpress
Angular js, Yeomon & Grunt
Wrangling the WordPress Template Hierarchy Like a Boss
Ad

Similar to Using Composer to create manageable WordPress websites (20)

PDF
Using Composer with WordPress - 2.0
PDF
WordPress modern development
PDF
Using composer with WordPress
PDF
Leveraging Composer in Existing Projects
PDF
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
PDF
Dependency management with Composer
PDF
WordCamp Sacramento 2019: Modernizing Your Development Workflow Using Composer
PDF
12 Composer #burningkeyboards
PDF
Php Dependency Management with Composer ZendCon 2016
PDF
composer_talk_20160209
PDF
Composer Helpdesk
PDF
Wordpress development: A Modern Approach
PDF
Php Dependency Management with Composer ZendCon 2017
PDF
Create a PHP Library the right way
PDF
Lecture11_LaravelGetStarted_SPring2023.pdf
PPTX
PHP Dependency Management with Composer
PPTX
A new way to develop with WordPress!
PDF
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
PDF
Composer in the wilderness by Josef Bielawski
PDF
Composer: Dependency Manager for PHP
Using Composer with WordPress - 2.0
WordPress modern development
Using composer with WordPress
Leveraging Composer in Existing Projects
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
Dependency management with Composer
WordCamp Sacramento 2019: Modernizing Your Development Workflow Using Composer
12 Composer #burningkeyboards
Php Dependency Management with Composer ZendCon 2016
composer_talk_20160209
Composer Helpdesk
Wordpress development: A Modern Approach
Php Dependency Management with Composer ZendCon 2017
Create a PHP Library the right way
Lecture11_LaravelGetStarted_SPring2023.pdf
PHP Dependency Management with Composer
A new way to develop with WordPress!
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
Composer in the wilderness by Josef Bielawski
Composer: Dependency Manager for PHP

More from Anna Ladoshkina (6)

PDF
WordPress-сообщество
PDF
Часто требуемые функции: решение с помощью плагинов для WordPress
PDF
Аналитика веб-сайта: доступные инструменты
PDF
Организация приема пожертвований на сайте. Как сделать это просто с Онлайн-Ле...
PDF
Анализ представленности фондов целевого капитала в сети
PDF
Адаптивный контент в WordPress.
WordPress-сообщество
Часто требуемые функции: решение с помощью плагинов для WordPress
Аналитика веб-сайта: доступные инструменты
Организация приема пожертвований на сайте. Как сделать это просто с Онлайн-Ле...
Анализ представленности фондов целевого капитала в сети
Адаптивный контент в WordPress.

Recently uploaded (20)

PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPTX
SAP Ariba Sourcing PPT for learning material
PDF
Sims 4 Historia para lo sims 4 para jugar
PDF
Testing WebRTC applications at scale.pdf
PPTX
presentation_pfe-universite-molay-seltan.pptx
PPTX
innovation process that make everything different.pptx
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PPTX
artificial intelligence overview of it and more
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PPTX
E -tech empowerment technologies PowerPoint
PDF
How to Ensure Data Integrity During Shopify Migration_ Best Practices for Sec...
PPTX
Introduction to Information and Communication Technology
PDF
Paper PDF World Game (s) Great Redesign.pdf
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PDF
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PPT
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
PptxGenJS_Demo_Chart_20250317130215833.pptx
SAP Ariba Sourcing PPT for learning material
Sims 4 Historia para lo sims 4 para jugar
Testing WebRTC applications at scale.pdf
presentation_pfe-universite-molay-seltan.pptx
innovation process that make everything different.pptx
Tenda Login Guide: Access Your Router in 5 Easy Steps
Decoding a Decade: 10 Years of Applied CTI Discipline
artificial intelligence overview of it and more
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
Module 1 - Cyber Law and Ethics 101.pptx
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
E -tech empowerment technologies PowerPoint
How to Ensure Data Integrity During Shopify Migration_ Best Practices for Sec...
Introduction to Information and Communication Technology
Paper PDF World Game (s) Great Redesign.pdf
Introuction about WHO-FIC in ICD-10.pptx
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
Cloud-Scale Log Monitoring _ Datadog.pdf
isotopes_sddsadsaadasdasdasdasdsa1213.ppt

Using Composer to create manageable WordPress websites