Nephtali 3.2.3 adds ability to set config mode by page, improves Postgre support, and improves developer experience
The most recent release of Nephtali (version 3.2.3) offers some simple enhancements, bug fixes, and improved documentation.
Page-by-page config mode
You can now easily change the configuration mode used for a page without having to change the whole site. For instance, if you’d like to put one page in ‘dev’ mode and keep the rest of the site in ‘prod’ mode, you’d just add the following snippet of PHP to the top of your markup file:
<?php $nephtali_config_mode = 'dev'; ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml">
To avoid potential security issues, you must specifically enable this feature by opening nconfig.php and adding a fifth argument to n\config\save():
Added support in n\sql\action\* functions for PostgresSQL lastInsertId
PostgreSQL’s use of sequences requires the name of the sequence object in the name parameter of PDO->lastInsertId() calls. To accommodate this in Nephtali, an optional last_insert_id_name parameter has been added to the following functions within the n\sql\action namespace:
- query($query, array $inputs, $dbh = null, $last_insert_id_name = null)
- insert($table_name, array $inputs, $dbh = null, $last_insert_id_name = null)
- save($table_name, array $inputs, $dbh = null, $last_insert_id_name = null)
Viewing debug output vs. automatic error handling
You can no longer control on a pipe-by-pipe basis whether an uncaught exception within a pipe function is automatically handled or not (you used to have to add ‘auto_error_handling’ => false to the $opts array for a pipe.) Going forward, the mode for the current request determines whether uncaught exceptions are automatically handled (i.e., the required ‘error’ view is shown) or the debug output is displayed. These changes are meant to simplify the development process and help Nephtali’s default configuration come inline with developers’ expectations.
The settings for the modes are as follow:
- dev – Show debug output.
- test – Automatically catch exceptions and display error view.
- prod – Automatically catch exceptions and display error view.
Nephtali now checks for typos in $opts array keys supplied to n\port\register() calls. This change avoids issues where a misspelled key silently has no impact on the port validation, a significant source of confusion for the developer who thought they had properly set up the port. The checks for typos only occur in ‘dev’ mode (this helps keep ‘prod’ mode fast as can be), and Nephtali will even recommend the associative key you meant to keep going by the closest valid spelling match.
Additionally, when one accidentally tries to change the value of an immutable n\val(), the error feedback has been improved.
Bug fixes and improved documentation
The n\arr\format() function has now been fixed so-as to properly return array values that don’t have any formatting functions applied to them. A big thanks goes out to Davin Granroth for reporting the issue.
Additionally, the documentation for several of Nephtali’s functions has improved significantly. Let me know if you see any issues.