truearrowsoftware / taslib
a small framework to handle PHP projects. Look for more details on github at https://github.com/TrueArrowSoftware/TASLibPHP
Requires
- php: >=8.2
- ext-curl: *
- ext-filter: *
- ext-json: *
- phpmailer/phpmailer: ~6.1
Requires (Dev)
- phpunit/phpunit: ~8.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-master
- 1.2.85
- 1.2.84
- 1.2.83
- 1.2.82
- 1.2.81
- 1.1.80
- 1.1.78
- 1.1.77
- 1.1.76
- 1.1.75
- 1.1.73
- 1.1.72
- 1.1.69
- 1.0.67
- 1.0.66
- 1.0.65
- 1.0.64
- 1.0.63
- 1.0.62
- 1.0.61
- 1.0.60
- 1.0.59
- 1.0.58
- 1.0.57
- 1.0.56
- 1.0.55
- 1.0.54
- 1.0.53
- 1.0.52
- 1.0.51
- 1.0.50
- 1.0.49
- 1.0.48
- 1.0.47
- 1.0.46
- 1.0.45
- 1.0.44
- 1.0.43
- 1.0.42
- 1.0.41
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-copilot/add-welcome-wiki-page
This package is auto-updated.
Last update: 2026-10-21 06:29:36 UTC
README
TASLibPHP (True Arrow Software Library for PHP) is a lightweight toolkit for building PHP web applications quickly, without the weight of a full framework. It gives you database access, data grids, validation, file handling, templating, email and async helpers under a single TAS\Core namespace.
Current version: 1.2.85
Table of Contents
- Features
- Requirements
- Installation
- Quick Start
- Usage Examples
- Configuration
- What's New in 1.2.85
- Running Tests
- Contributing
- Security
- License
Features
| Area | Classes | What you get |
|---|---|---|
| Database | DB, DirectConnection |
MySQLi wrapper with prepared-statement support, insert/update/upsert helpers, bulk inserts, JSON export |
| Async | Async\DBPool, Async\AsyncQuery, Async\AsyncHttp, Async\FiberRunner |
Connection pooling, parallel MySQL queries, parallel HTTP requests, Fiber-based task runner |
| Data Grid | Grid, GridFilter\*, UI\GridBootstrap |
Sortable, paged HTML grids with header filters, totals, row actions and Bootstrap rendering |
| Entities | Entity |
Base model with table-driven validation, loading from DB/array and JSON serialization |
| Validation & Formatting | DataValidate, DataFormat |
Input validation, sanitizing, date/number/currency formatting |
| HTML & UI | HTML, UI, WebUI\* |
Form inputs, dropdowns from arrays or record sets, date/time elements |
| Templating | TemplateHandler |
Keyword-based templates and navigation menu generation |
| Files | UserFile, ImageFile, DocumentFile, CSVHandler, IO, FTP |
Uploads, image processing, documents, CSV import/export, FTP transfer |
| Assets | Assets\AssetManager |
Asset registration and output for pages |
| Infrastructure | Config, Cron, Log, Permission, Web, Utility, ArrayHelper |
Configuration, scheduled jobs, logging, role permissions, HTTP and array utilities |
| via PHPMailer | SMTP mail with configurable TLS/auth |
Requirements
- PHP 8.2 or higher
- MySQL / MariaDB (via
mysqli, withmysqlndfor async queries) - PHP extensions:
curl,json,filter,mysqli - Composer
Installation
composer require truearrowsoftware/taslib
To pin this release:
composer require truearrowsoftware/taslib:1.2.85
Quick Start
- Copy
sample/configure.phpto your project root and adjust it for your environment. - Optionally create
configure.local.phpnext to it for machine-specific settings (keep it out of version control). - Include the configuration at the top of every entry point:
<?php require_once __DIR__ . '/configure.php'; $users = $GLOBALS['db']->ExecuteAll('SELECT UserID, Name FROM users WHERE Status = ?', [1]);
configure.php loads the Composer autoloader, connects $GLOBALS['db'], and fills $GLOBALS['AppConfig'].
Usage Examples
Database
All query methods accept an optional array of values. When values are passed, the query runs as a prepared statement, so user input never needs manual escaping.
$db = $GLOBALS['db']; // Result set $rs = $db->Execute('SELECT * FROM orders WHERE CustomerID = ? AND Total > ?', [$customerId, 100.0]); while ($row = $db->FetchArray($rs)) { echo $row['OrderID'], PHP_EOL; } // Single value / single row / all rows $count = $db->ExecuteScalar('SELECT COUNT(*) FROM orders WHERE CustomerID = ?', [$customerId]); $order = $db->ExecuteScalarRow('SELECT * FROM orders WHERE OrderID = ?', [$orderId]); $rows = $db->ExecuteAll('SELECT * FROM orders WHERE Status = ?', ['open']); // Write helpers $db->Insert('orders', ['CustomerID' => $customerId, 'Total' => 250.00]); $newId = $db->GeneratedID(); $db->Update('orders', ['Total' => 300.00], $newId, 'OrderID'); $db->Delete('orders', $newId, 'OrderID');
Data Grid
use TAS\Core\Grid; $GLOBALS['Tables']['orders'] = 'orders'; // offset paging looks the grid's tablename up here $options = Grid::DefaultOptions(); $options['gridid'] = 'orders'; $options['gridurl'] = 'orders.php'; $options['fields'] = [ 'OrderID' => ['name' => 'Order #', 'type' => 'number'], 'Customer' => ['name' => 'Customer', 'type' => 'string'], 'Total' => ['name' => 'Total', 'type' => 'currency', 'showtotal' => true], 'CreatedOn' => ['name' => 'Created', 'type' => 'date'], 'IsPaid' => ['name' => 'Paid', 'type' => 'onoff'], ]; $query = Grid::DefaultQueryOptions(); $query['basicquery'] = 'SELECT o.OrderID, c.Name AS Customer, o.Total, o.CreatedOn, o.IsPaid FROM orders o JOIN customers c ON c.CustomerID = o.CustomerID'; $query['indexfield'] = 'OrderID'; $query['tablename'] = 'orders'; $query['defaultorderby'] = 'OrderID'; $query['defaultsortdirection'] = 'desc'; echo (new Grid($options, $query))->Render();
Supported column types include string, longstring, number/numeric, currency, date, datetime, phone, onoff, flag, globalarray and callback.
Grid Header Filters
Enable header filters with showheaderfilter. Each column picks a filter by type (text for most, a date picker for date/datetime), or you can set one explicitly with the filter key:
use TAS\Core\GridFilter\SelectFilter; use TAS\Core\GridFilter\DateFilter; $options['showheaderfilter'] = true; $options['filterdata'] = $_POST; // Dropdown from a static array $options['fields']['Status']['filter'] = new SelectFilter(['open' => 'Open', 'closed' => 'Closed']); // Dropdown from a query (value column, label column) $options['fields']['Customer']['filter'] = new SelectFilter( 'SELECT CustomerID, Name FROM customers ORDER BY Name', 'CustomerID', 'Name' ); // Date range (renders "{gridid}-filter-{field}" and "...-end" inputs) $options['fields']['CreatedOn']['filter'] = new DateFilter(range: true);
Filters only render inputs. Building the WHERE clause from the posted values stays in your code. Custom filters implement TAS\Core\GridFilter\IGridFilter.
Parallel Queries
With a DBPool, independent queries run at the same time over separate connections:
use TAS\Core\Async\DBPool; use TAS\Core\Async\AsyncQuery; $GLOBALS['dbpool'] = new DBPool(HOST, LOCAL_USER, LOCAL_PASSWORD, LOCAL_DB, maxConnections: 5); $results = AsyncQuery::runParallel([ 'orders' => 'SELECT * FROM orders ORDER BY OrderID DESC LIMIT 10', 'customers' => 'SELECT COUNT(*) FROM customers', ], $GLOBALS['dbpool']);
When $GLOBALS['dbpool'] is set, Grid automatically runs its data query, count query and any query-based SelectFilter sources in parallel.
Configuration
Key settings in configure.php / configure.local.php:
| Setting | Description |
|---|---|
HOST, LOCAL_USER, LOCAL_PASSWORD, LOCAL_DB |
Database connection |
URL_FOLDERPATH |
Web root folder path |
ADMIN_EMAIL |
Administrator email address |
$GLOBALS['AppConfig']['DeveloperMode'] |
Verbose error reporting |
$GLOBALS['AppConfig']['PageSize'] |
Default grid page size |
$GLOBALS['AppConfig']['UseSMTPAuth'], SMTPServer, SMTPServerPort, SMTP-TLS |
Outgoing mail |
$GLOBALS['AppConfig']['UploadPath'], TemplatePath, cache |
File system locations |
A reference database schema is available in database/db.sql.
What's New in 1.2.85
- Seek paging for grids: set
'pagingmode' => 'seek'in theGridoptions (or in the$paramofUI::HTMLGridFromRecordSet/UI::HTMLGridForPublic) to page with an anchor row (KeysetPager) instead of a deepOFFSET. Mark sort columns with'seek' => 'sql expression'(ortrue); non-seekable shapes or stale tokens fall back to offset paging, so every URL still returns the right page. - Security: grid sort column (
ob) and direction (d) are now validated, closing an SQL injection through the sort URL parameters. Upgrade if you useGridwith request-driven sorting.
Full history: CHANGELOG.md.
1.2.84
- PHP 8.2+ is now required.
- Prepared statements everywhere:
Execute,ExecuteScalar,ExecuteScalarRowandExecuteAllaccept a values array. - Pluggable grid filters: new
GridFilternamespace withTextFilter,DateFilter(single date or range) andSelectFilter(array or SQL source), plus theIGridFilterinterface for custom filters. - Faster grids: query-based dropdown filters load in the same parallel batch as the grid data when a
DBPoolis configured. - Fixed the filter header row so every column cell is closed correctly.
Running Tests
composer install
cp test/configure.local.sample.php test/configure.local.php # set your test DB credentials
php ./vendor/bin/phpunit --bootstrap ./test/bootstrap.php ./test
Contributing
Bug reports, feature requests and pull requests are welcome on GitHub. See CONTRIBUTING.md for how to report bugs, send patches and the test and style requirements (new features need a PHPUnit test).
Security
Please report vulnerabilities privately, as described in SECURITY.md. Fixes are listed under the Security heading of each release in the CHANGELOG.
License
Released under the MIT License. © True Arrow Software.
Note: TASLibPHP is under active development. Some components are not yet fully covered by tests. Read the documentation and the API reference, and check the changelog when upgrading.