Skip to content

Repository files navigation

pdoTools

Tests PHP Coverage

pdoTools 3 is a set of everyday MODX Revolution 3 snippets plus a small library that keeps them fast. Queries are built with xPDO and run through PDO. Elements can live in the database or in files. MiniShop3 use it.

This branch requires MODX 3 and PHP 8.1+. For MODX 2 use pdoTools 2.x.

Documentation: docs.modx.pro/components/pdotools

Tests

From core/components/pdotools:

composer install
composer test

Integration tests need a live MODX 3 tree (CI installs 3.2.4-pl and the transport with PKG_AUTO_INSTALL=true):

export MODX_TEST_BASE=/path/to/modx/
composer test:integration

Coverage (pcov or xdebug): composer test:coverage. HTML report lands in coverage/html.

Advantages

Every pdoTools snippet shares the same core:

  • Database work goes through PDO. xPDO objects are created only when needed.
  • Simple placeholders in chunks are preprocessed so the MODX parser only handles complex tags.
  • TV parameters are sorted, prepared, processed, and output correctly.
  • Chunk code can sit inline in the snippet call, in a normal chunk, or in a static file (@FILE, @INLINE, @TEMPLATE).
  • Fast placeholders wrap a value in tags only when it is not empty (covers many isempty-style cases).
  • A timed work log for debugging bottlenecks. Snippet logs go into a matching placeholder (pdoResourcesLog, pdoPageLog, …).

Queries can target any tables, with joins and conditions. Pagination stays compatible with getPage via pdoPage. The package includes the Fenom template engine.

Compared with stock MODX helpers:

  • pdoTools::getChunk() processes placeholders faster than modX::getChunk().
  • pdoTools::runSnippet() is faster and more powerful than modX::runSnippet().

These snippets usually run faster when you select more fields in a single query.

Composition

Classes live under ModxPro\PdoTools\ (PSR-4). The service container still accepts the aliases pdoTools and pdoFetch.

Snippets

Snippet Role
pdoResources Resource lists (parameter-compatible replacement for getResources)
pdoMenu Menus (Wayfinder replacement)
pdoPage Pagination (getPage replacement)
pdoCrumbs Breadcrumbs (BreadCrumb replacement)
pdoUsers Users, with role and group filters
pdoSitemap Sitemap generation (GoogleSiteMap replacement)
pdoNeighbors Links to neighboring resources
pdoField Any resource field (getResourceField / UltimateParent replacement)
pdoTitle Page title helper
pdoArchive Archive listings by date

Classes

Class Docs
pdoTools ModxPro\PdoTools\CoreTools — core helpers (getChunk, runSnippet, caching, …)
pdoFetch ModxPro\PdoTools\Fetch — query builder and PDO fetch layer
pdoParser ModxPro\PdoTools\Parsing\Parser — parser integration (Fenom / FastField tags)

More documentation

Links

About

pdoTools for MODX Revolution 3.x

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages