Download the PHP package forrest79/phpgsql-nette without Composer
On this page you can find all versions of the php package forrest79/phpgsql-nette. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download forrest79/phpgsql-nette
More information about forrest79/phpgsql-nette
Files in forrest79/phpgsql-nette
Package phpgsql-nette
Short Description PhPgSql implementation into Nette Framework.
License BSD-3-Clause
Informations about the package phpgsql-nette
PhPgSql - Nette
Use PhPgSql with Nette Framework.
Introduction
Extension to easy use PhPgSql in Nette application.
Installation
The recommended way to install PhPgSql - Nette is through Composer:
PhPgSql requires PHP 8.1.0 and pgsql binary extension.
Using
First, register extension in neon configuration:
Then, register connection (one connection is as default):
Or multiple connections:
IMPORTANT! You can't name connection as
config
.
First connection
is autowired as Forrest79\PhPgSql\Fluent\Connection
. If you want to autowired other connection or none connection, you must explicitly set autowired: false
.
You can also get a connection by:
Second can be got by:
Use your own connection class
By default Forrest79\PhPgSql\Fluent\Connection
is registered to DI as connection class. If you want to use other (your own) connection class, you need to use your own connection factory. This is class that implements Forrest79\PhPgSql\Nette\Connection\ConnectionCreator
interface, and you must specify the concrete return type with your connection class.
Example:
Function prepareConfig(array $config)
create connection string (key='value' key='value' ...
) from the array with configuration. Items with NULL
values are skipped.
And now, you just need to override old connection factory with this one in DI configuration, services
section, like this:
Where default
is connection name.
Query dumper
SQL queries are dumped in Tracy\Bar
and in Tracy\Bluescreen
and you can use different dumpers/formatters. Three are included:
PhPgSql\Tracy\QueryDumpers\NullDumper
- show SQL query as it is, it is used whenqueryDumper: false
is setPhPgSql\Tracy\QueryDumpers\Basic
- highlight and format SQL query with basic internal formatter, it is used whenqueryDumper: null
andDoctrine\Sql-Formatter
is not installedPhPgSql\Tracy\QueryDumpers\SqlFormatter
- highlight and format SQL query with Doctrine\Sql-Formatter, it is used whenqueryDumper: null
andDoctrine\Sql-Formatter
is installed
You can install better formatting via
Doctrine\Sql-Formatter
just for your dev environment withcomposer require doctrine/sql-formatter --dev
.
Or you can use your own query dumper, just create a class-extending abstract class PhPgSql\Tracy\QueryDumper
, register it to the DI container and set service to queryDumper: @class/serviceName
Tracy BarPanel
BarPanel
for Tracy
with DB queries is showing links to PHP source files, where the query was sent to the database. This is made using PHP function debug_backtrace()
.
This function returns the whole call stack. To get the correct place in the PHP source file, we must ignore some internal library classes where the query is sent to the database in real.
Basically, BarPanel
ignores all classes/function from PhPgSql library to show the most accurate place in the PHP source.
When you use some own custom wrapping objects, you want to ignore in the call stack, you can extend backtraceContinueIterate()
method and add your own logic here. For example: