BUILDING A WEB APP ON WORDPRESS THE GOOD, THE BAD & THE UGLY Nathan Tyler @croixhaug nathan@tylerdigital.com https://stagingpilot.com
WHY BUILD AN APP ON WORDPRESS • Matt Mullenweg has mentioned using WP as an app framework several times over the last few years • WP REST API opens up lots of possibilities to break out of the CMS mold • There are 45,619 free plugins available in the WordPress plugin directory to get you started
PRO: WP REST API Built-in support for CPTs Easy custom endpoints Security, authentication, response codes, validation are all handled
PRO: USER AUTH/CAPABILITIES Registration, login, lost password, etc. Passwords, security, limit logins, captcha Powerful and Flexible Permissions
PRO: 3RD PARTY PLUGINS Rapid prototyping All things built to work within the WP ecosystem
CON: PLUGINS EXPECT WP-ADMIN Plugin functionality is built to be managed in wp-admin To make front-end “app” interfaces, you lose 50%+ of using existing plugins
CON: DATABASE & ENVIRONMENTS Lots of functionality is tied to the database No built-in concept of Environments (for dev/testing/production) Quick wins with 3rd party plugins now present challenges
CON: BUILT FOR PAGE LOAD IN BROWSER For long-running background jobs, you have to fight WP’s built-in cache for queries and postmeta
BUILDING A WORKFLOW FOR SEAMLESS WORDPRESS UPDATES Take screenshot Update plugin Take Screenshot Compare images Process comparison and rollback with error, or commit & deploy
Update Workflow * Take screenshot * Update plugin * Take Screenshot * Process Comparison * * (automated browser tests) Rollback update * or * Deploy to production site * JOB QUEUES This workflow is too long to do all in one step, we use a job queue Like a job board, with employers, job postings, and workers
JOB QUEUE PROS & CONS + run big tasks in background + run multiple tasks in parallel + error-prone jobs (api rate limits or unreliable 3rd party) + workers in different languages + queuing (less crashes) + scaling (more workers) - complicates dev, debug & testing - long-living workers can introduce new issues (WPQuery/ACF cache/memory leaks)
INTERACTIVE TESTING Virtual web browser execute complex functionality registration pages, private login areas, e-commerce checkout, interactive elements, etc.
TRY THIS AT HOME • Setup beanstalkd on Digital Ocean step by step tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-beanstalkd-work-queue-on-a-vps • Download Pheanstalk library https://github.com/pda/pheanstalk • Create a queue, provider, and worker (as part of WP or just PHP by itself) • Ideas to try: API call, large/slow/background jobs, handle/ process uploads
SHOULD YOU USE WORDPRESS AS AN APP FRAMEWORK? + Registration/Authentication - Everything tied to the database + REST API - Handling environments + Existing code and plugins dev/staging/testing/production + Rapid prototyping - WP Core (and third party plugins) are + Strong admin interface for all built for the majority (WP as CMS) - Prototyping => Refactoring & migration later managing your app
Thank you! I’m happy to answer any questions (now or anytime) @croixhaug nathan@tylerdigital.com https://stagingpilot.com
Recommend
More recommend