Download the PHP package daycry/doctrine without Composer
On this page you can find all versions of the php package daycry/doctrine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download daycry/doctrine
More information about daycry/doctrine
Files in daycry/doctrine
Package doctrine
Short Description Doctrine for Codeigniter 4
License MIT
Homepage https://github.com/daycry/doctrine
Informations about the package doctrine
Doctrine
Doctrine for Codeigniter 4
Documentation Index
- Installation
- Configuration
- Usage
- CLI Commands
- Using DataTables
- DataTables Search Modes
- Viewing Doctrine Queries in the Debug Toolbar
Installation via composer
Use the package with composer install
> composer require daycry/doctrine
Configuration
Run command:
> php spark doctrine:publish
This command will copy a config file to your app namespace and "cli-config.php" file for doctrine cli.
Then you can adjust it to your needs. By default file will be present in app/Config/Doctrine.php
.
Usage Loading Library
Usage as a Service
Usage as a Helper
In your BaseController - $helpers array, add an element with your helper filename.
And then, you can use the helper
Cli Commands
If you receive the followrin error: [Semantical Error] The annotation "@JMS\Serializer\Annotation\ExclusionPolicy" in class App\Models\Entity\Secret was never imported. Did you maybe forget to add a "use" statement for this annotation?
You must execute the following command
Using DataTables
Usage with doctrine/orm:
If you receive an error: Not all identifier properties can be found in the ResultSetMapping you can use:
Example
Search
To search from datatables there are nine different search modes
Mode | Pattern | Desctiption |
---|---|---|
LIKE '…%' | [*%]searchTerm | This performs a LIKE '…%' search where the start of the search term must match a value in the given column. This can be archived with only providing the search term (because it's default) or by prefixing the search term with "[%]" ([%]searchTerm). |
LIKE '%…%' | [%%]searchTerm | This performs a LIKE '%…%' search where any part the search term must match a value in the given column. This can be archived by prefixing the search term with "[%%]" ([%%]searchTerm). |
Equality | [=]searchTerm | This performs a = … search. The search term must exactly match a value in the given column. This can be archived by prefixing the search term with "[=]" ([=]searchTerm). |
!= (No Equality) | [!=]searchTerm | This performs a != … search. The search term must not exactly match a value in the given column. This can be archived by prefixing the search term with "[!=]" ([!=]searchTerm). |
> (Greater Than) | [>]searchTerm | This performs a > … search. The search term must be smaller than a value in the given column. This can be archived by prefixing the search term with "[>]" ([>]searchTerm). |
< (Smaller Than) | [<]searchTerm | This performs a < … search. The search term must be greater than a value in the given column. This can be archived by prefixing the search term with "[<]" ([<]searchTerm). |
< (IN) | [IN]searchTerm,searchTerm,… | This performs an IN(…) search. One of the provided comma-separated search terms must exactly match a value in the given column. This can be archived by prefixing the search terms with "[IN]" ([IN]searchTerm,searchTerm,…). |
< (OR) | [OR]searchTerm,searchTerm,… | This performs multiple OR-connected LIKE('%…%') searches. One of the provided comma-separated search terms must match a fragment of a value in the given column. This can be archived by prefixing the search terms with "[OR]" ([OR]searchTerm,searchTerm,…). |
>< (Between) | [><]searchTerm,searchTerm | This performs a BETWEEN … AND … search. Both search terms must be separated with a comma. This operation can be archived by prefixing the comma-separated search terms with "[><]" ([><]searchTerm,searchTerm). |
Prefixes are case-insenstive (IN, in, OR, or). Provided search terms were trimmed.
Example
Viewing Doctrine Queries in the Debug Toolbar
This library allows you to view all SQL queries executed by Doctrine directly in the CodeIgniter 4 Debug Toolbar, making it easier to analyze and debug your database interactions.
How does it work?
- A custom Collector (
DoctrineCollector
) and Middleware (DoctrineQueryMiddleware
) are included to capture all queries executed by Doctrine. - The Middleware is automatically integrated when you instantiate
\Daycry\Doctrine\Doctrine
. - The Collector exposes the query information to the Toolbar, letting you see queries in real time.
Integration steps
-
Register the Collector in the Toolbar
Open your
app/Config/Toolbar.php
file and add the Doctrine Collector to the$collectors
array: -
Use the Doctrine class as usual
When you instantiate
\Daycry\Doctrine\Doctrine
(as a service, helper, or manually), the Middleware is automatically enabled and queries will be captured. -
View queries in the Toolbar
Whenever you execute any query with Doctrine, you will see a new "Doctrine" tab in the CodeIgniter 4 Debug Toolbar, showing all SQL queries executed during the current request.
Notes and troubleshooting
- You do not need to call any method manually to enable the Collector or Middleware.
- If you do not see the "Doctrine" tab in the Toolbar, make sure the Collector is registered in
Toolbar.php
and that the Toolbar is enabled in your environment. - Fully compatible with advanced connections (SQLite3, SSL, custom options) and Doctrine DBAL 4+.
All versions of doctrine with dependencies
doctrine/orm Version ^3
doctrine/dbal Version ^4
symfony/cache Version ^7
beberlei/doctrineextensions Version ^1.0
jms/serializer-bundle Version ^5