{"id":16487329,"url":"https://github.com/leoloso/pop-api-wp","last_synced_at":"2026-03-06T16:31:11.482Z","repository":{"id":62516839,"uuid":"184531970","full_name":"leoloso/PoP-API-WP","owner":"leoloso","description":"Bootstrap a PoP API for WordPress","archived":false,"fork":false,"pushed_at":"2020-05-21T11:38:33.000Z","size":139,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-12T13:33:43.980Z","etag":null,"topics":["bootstrap","pop","wordpress"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leoloso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-02T06:28:49.000Z","updated_at":"2023-07-29T03:23:28.000Z","dependencies_parsed_at":"2022-11-02T13:31:05.940Z","dependency_job_id":null,"html_url":"https://github.com/leoloso/PoP-API-WP","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoloso%2FPoP-API-WP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoloso%2FPoP-API-WP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoloso%2FPoP-API-WP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoloso%2FPoP-API-WP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leoloso","download_url":"https://codeload.github.com/leoloso/PoP-API-WP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224305847,"owners_count":17289446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bootstrap","pop","wordpress"],"created_at":"2024-10-11T13:33:45.039Z","updated_at":"2026-03-06T16:31:11.449Z","avatar_url":"https://github.com/leoloso.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bootstrap a PoP API for WordPress\n\nQuickly launch a WordPress instance with the PoP API, REST and GraphQL installed.\n\n## Install\n\nPoP requires PHP 7.1 or higher.\n\n### Installing PoP on an existing WordPress site\n\nVia a WordPress plugin:\n\n_Coming soon..._\n\n-----\n\nVia Composer:\n\n1. Make sure your `composer.json` file has the configuration below to accept minimum stability `\"dev\"` (there are no releases for PoP yet, and the code is installed directly from the `master` branch):\n\n```javascript\n{\n    ...\n    \"minimum-stability\": \"dev\",\n    \"prefer-stable\": true,\n    ...\n}\n```\n\n2. Add the following packages to the `require` section of your `composer.json` file:\n\n\n```bash\n{\n    \"require\": {\n        \"getpop/commentmeta-wp\": \"dev-master\",\n        \"getpop/pages-wp\": \"dev-master\",\n        \"getpop/postmeta-wp\": \"dev-master\",\n        \"getpop/taxonomyquery-wp\": \"dev-master\",\n        \"getpop/usermeta-wp\": \"dev-master\",\n        \"getpop/postmedia-wp\": \"dev-master\",\n        \"getpop/graphql\": \"dev-master\",\n        \"getpop/api-rest\": \"dev-master\",\n        \"getpop/api-endpoints-for-wp\": \"dev-master\",\n        \"getpop/engine-wp-bootloader\": \"dev-master\",\n    }\n}\n```\n\n3. Add the following code at the beginning of `wp-config.php`:\n\n```php\n// Load Composer’s autoloader\nrequire_once (__DIR__.'/vendor/autoload.php');\n\n// Initialize all PoP components\n$componentClasses = [\n    \\PoP\\CommentMetaWP\\Component::class,\n    \\PoP\\PagesWP\\Component::class,\n    \\PoP\\PostMetaWP\\Component::class,\n    \\PoP\\PostMediaWP\\Component::class,\n    \\PoP\\TaxonomyQueryWP\\Component::class,\n    \\PoP\\UserMetaWP\\Component::class,\n    \\PoP\\GraphQL\\Component::class,\n    \\PoP\\RESTAPI\\Component::class,\n    \\PoP\\APIEndpointsForWP\\Component::class,\n];\nforeach ($componentClasses as $componentClass) {\n    $componentClass::initialize();\n}\n```\n\n\u003c!-- \u003e Note: Only package `\"getpop/engine-wp\"` is mandatory. The other ones are suggested to load data from posts, users, comments and taxonomies, and to add pretty API endpoints --\u003e\n\n4. Download and install the packages in your project:\n\n```bash\n$ composer update\n```\n\n\u003e Note: you will most likely need to wait for a few minutes ☕️😁\n\n5. Flush the re-write rules to enable the API endpoint:\n\n- Log-in to the WordPress admin\n- Go to `Settings =\u003e Permalinks`\n- Click on the \"Save Changes\" button (no need to modify any input)\n\n6. ✅ Check that the PoP API works by loading in your site: `/api/?query=fullSchema`\n\n**Optionals:**\n\n1. To accept external API queries, add the snippet below in file `.htaccess`:\n\n```apache\n\u003cIfModule mod_rewrite.c\u003e\n# Enable the server to accept external API queries\nHeader set Access-Control-Allow-Methods \"OPTIONS, GET, POST\"\nHeader set Access-Control-Allow-Headers \"origin, content-type\"\nHeader set Access-Control-Allow-Origin \"*\"\n\u003c/IfModule\u003e\n```\n\n2. Enable pretty permalinks for the API through the `.htaccess` file\n\nInstead of adding dependency `\"getpop/api-endpoints-for-wp\"` and having to flush the permalinks, you can add pretty permalinks for the API endpoints (such as `/api/graphql`) by adding the following code in the `.htaccess` file (before the WordPress rewrite code, which starts with `# BEGIN WordPress`):\n\n```apache\n# Pretty permalinks for API\n  # a. Resource endpoints\n    # 1. GraphQL or REST: /some-url/api/graphql\n    # 2. REST: /some-url/api/rest\n    # 3. PoP native: /some-url/api\n  # b. Homepage single endpoint (root)\n    # 1. GraphQL or REST: /api/graphql\n    # 2. REST: /api/rest\n    # 3. PoP native: /api\n\u003cIfModule mod_rewrite.c\u003e\nRewriteEngine On\nRewriteBase /\n\n# a. Resource endpoints\n# 1 and 2. GraphQL or REST: Rewrite from /some-url/api/(graphql|rest)/ to /some-url/?scheme=api\u0026datastructure=(graphql|rest)\nRewriteCond %{SCRIPT_FILENAME} !-d\nRewriteCond %{SCRIPT_FILENAME} !-f\nRewriteRule ^(.*)/api/(graphql|rest)/?$ /$1/?scheme=api\u0026datastructure=$2 [L,P,QSA]\n\n# 3. PoP native: Rewrite from /some-url/api/ to /some-url/?scheme=api\nRewriteCond %{SCRIPT_FILENAME} !-d\nRewriteCond %{SCRIPT_FILENAME} !-f\nRewriteRule ^(.*)/api/?$ /$1/?scheme=api [L,P,QSA]\n\n# b. Homepage single endpoint (root)\n# 1 and 2. GraphQL or REST: Rewrite from api/(graphql|rest)/ to /?scheme=api\u0026datastructure=(graphql|rest)\nRewriteCond %{SCRIPT_FILENAME} !-d\nRewriteCond %{SCRIPT_FILENAME} !-f\nRewriteRule ^api/(graphql|rest)/?$ /?scheme=api\u0026datastructure=$1 [L,P,QSA]\n\n# 3. PoP native: Rewrite from api/ to /?scheme=api\nRewriteCond %{SCRIPT_FILENAME} !-d\nRewriteCond %{SCRIPT_FILENAME} !-f\nRewriteRule ^api/?$ /?scheme=api [L,P,QSA]\n\u003c/IfModule\u003e\n```\n\n### Creating a new WordPress site with PoP installed\n\nVia [Composer](https://getcomposer.org) and [WP-CLI](https://wp-cli.org/) (installed globally):\n\n1. Create the [WordPress database and user](https://wordpress.org/support/article/how-to-install-wordpress/#step-2-create-the-database-and-a-user)\n2. Configure WordPress through environment variables: \n\n\u003e Copy the code below to an editor, replace all values (such as `{YOUR_SITE_DB_NAME}`) with your own values, and then either paste it on the terminal to execute, or save it in file \"~/.bash_profile\" and then execute `source ~/.bash_profile`.\n\n```bash\nexport DB_NAME={YOUR_SITE_DB_NAME} #eg: database\nexport DB_USER={YOUR_SITE_DB_USER} #eg: admin\nexport DB_PASSWORD={YOUR_SITE_DB_PASSWORD} #eg: sADF!kl9diq@#Sjfk\nexport DB_HOST={YOUR_SITE_DB_HOST} #eg: 127.0.0.1\nexport SITE_URL_WITHOUT_HTTP={YOUR_SITE_URL_WITHOUT_HTTP} #eg: localhost\nexport SITE_URL_WITH_HTTP={YOUR_SITE_URL_WITH_HTTP} #eg: http://localhost\nexport SITE_NAME=\"{YOUR_SITE_NAME}\" #eg: \"My awesome website\"\nexport ADMIN_USER={ADMIN_USER} #eg: admin\nexport ADMIN_PASSWORD={ADMIN_PASSWORD} #eg: JKo$@sfjASD00w\nexport ADMIN_EMAIL={ADMIN_EMAIL} #eg: pedro@example.com\n```\n\nTo set the SALT keys there are two alternatives:\n\na. Set random values through environment variable `SHUFFLE_SALT_KEYS`:\n\n```bash\nexport SHUFFLE_SALT_KEYS=true\n```\n\nb. Set the corresponding values directly:\n\n```bash\n# Obtain random values from https://api.wordpress.org/secret-key/1.1/salt\nexport AUTH_KEY={YOUR_AUTH_KEY}\nexport SECURE_AUTH_KEY={YOUR_SECURE_AUTH_KEY}\nexport LOGGED_IN_KEY={YOUR_LOGGED_IN_KEY}\nexport NONCE_KEY={YOUR_NONCE_KEY}\nexport AUTH_SALT={YOUR_AUTH_SALT}\nexport SECURE_AUTH_SALT={YOUR_SECURE_AUTH_SALT}\nexport LOGGED_IN_SALT={YOUR_LOGGED_IN_SALT}\nexport NONCE_SALT={YOUR_NONCE_SALT}\n```\n\n3. Bootstrap a new project from this repo:\n\n```bash\n$ composer create-project leoloso/pop-api-wp\n```\n\n\u003e Note: you will most likely need to wait for a few minutes ☕️😁\n\n4. Execute `install` again to copy the WordPress must-use plugins under folder `/mu-plugins` (somehow it doesn't do it with `create-project`). `cd` into the project's folder (by default `\"pop-api-wp\"`) and execute:\n\n```bash\n$ composer install\n```\n\n5. Flush the re-write rules to enable the API endpoint:\n\n- Log-in to the WordPress admin\n- Go to `Settings =\u003e Permalinks`\n- Click on the \"Save Changes\" button (no need to modify any input)\n\n6. ✅ The site is installed under:\n\n- 👉 WordPress site: `{YOUR_SITE_URL_WITH_HTTP}`\n- 👉 WordPress admin: `{YOUR_SITE_URL_WITH_HTTP}`/wp/wp-admin/\n- 👉 PoP API: `{YOUR_SITE_URL_WITH_HTTP}/api/?query=fullSchema`\n\n**Optionals:**\n\n1. Configure application options through environment variables. \n\nPoP relies on [Symfony's Dotenv component](https://symfony.com/doc/current/components/dotenv.html) to define environment variables through file `config/.env`. You can create or further edit this file, and create additional localized `.env` files (such as `.env.local`, as detailed in the [component's documentation](https://symfony.com/doc/current/components/dotenv.html)).\n\n\u003c!--\n## Installed Components\n\nThis bootstrapper will install the following components (for WordPress):\n\n- [Posts](https://github.com/getpop/posts)\n- [Users](https://github.com/getpop/users)\n- [Taxonomies](https://github.com/getpop/taxonomies) (tags and categories)\n- [Comments](https://github.com/getpop/comments)\n- [Pages](https://github.com/getpop/pages)\n- [Media](https://github.com/getpop/media)\n\n## Usage\n\nRefer to [PoP API](https://github.com/getpop/api)\n--\u003e\n\n## Credits\n\n- [Leonardo Losoviz][link-author]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[link-author]: https://github.com/leoloso\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoloso%2Fpop-api-wp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleoloso%2Fpop-api-wp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoloso%2Fpop-api-wp/lists"}