PHPackages                             agrandesr/sql-custom-action - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. agrandesr/sql-custom-action

ActiveLibrary[Database &amp; ORM](/categories/database)

agrandesr/sql-custom-action
===========================

This Custom Action is a implementation for the Agile Router library to make easy and quick SQL calls.

03PHP

Since Apr 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/AGrandesR/sql-custom-action)[ Packagist](https://packagist.org/packages/agrandesr/sql-custom-action)[ RSS](/packages/agrandesr-sql-custom-action/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SQLAction
=========

[](#sqlaction)

*This package is an extension of Agrandesr/agile-router (v1.0+).*

This Custom Action is a first easy implementation of PDO for mysql over Agile Router to send emails in a very easy way using the Custom Actions of Agile Router.

Installation
------------

[](#installation)

First we need to require the package:

```
composer require agrandesr/sql-custom-action
```

Next, we need to add to the Router before the run method.

```
require './vendor/autoload.php';

use Agrandesr\Router;

$router = new Router();

$router->addCustomAction('mail','App\\CustomActions\\SQLAction');

$router->run();
```

Next you have to modify .env file with your sql connection data:

```
SQL_TYPE=mysql
SQL_HOST=localhost
SQL_USER=root
SQL_PASS=******
SQL_DTBS=test
SQL_PORT=3306
SQL_CHAR=UTF8
```

Now you can use the new action in your routes file.

```
{
    "sql":{
        "query":{
            "execute":[
                {
                    "name":"user",
                    "type":"sql-action",
                    "content":{
                        "sql":"SELECT * FROM users WHERE id like ?",
                        "params":[
                            "1"
                        ]
                    }
                },
                {
                    "type":"json",
                    "content":{
                        "body":{
                            "user":"||user.0.mail||"
                        }
                    }
                }
            ]
        }
    }
}
```

And that is all, you can create a endpoint to send a email very easy.

Content parameters
------------------

[](#content-parameters)

Like you can see in the example, the action "PhpMailer" have the next parameters:

- sql\['required'\]: This is the sql sentence that you want to execute. You can follow PDO to make queries.
- values\['optional'\]: This is the place to add the values to the query.

ENV variables
-------------

[](#env-variables)

You can have more than one SQL connection setted for one project using envFlag. The envFlag adds the value of the endFlag in the middle of your envFlag key. For example:

```
{
    "sql":{
        "GET":{
            "execute":[
                {
                    "type":"sql",
                    "content":{
                        "envFlag":"CALIFORNIA",
                        "sql":"SELECT * FROM id=?",
                        "values":[1]
                    }
                },
                {
                    "type":"sql",
                    "content":{
                        "envFlag":"TEXAS",
                        "sql":"SELECT * FROM id=:id",
                        "values":{
                            "id":1
                        }
                    }
                }
            ]
        }
    }
}
```

For the last example you have to complete other env variables:

```
SQL_CALIFORNIA_TYPE=mysql
SQL_CALIFORNIA_HOST=localhost
SQL_CALIFORNIA_USER=root
SQL_CALIFORNIA_PASS=*******
SQL_CALIFORNIA_DTBS=test
SQL_CALIFORNIA_PORT=3306
SQL_CALIFORNIA_CHAR=UTF8

SQL_TEXAS__TYPE=mysql
SQL_TEXAS__HOST=localhost
SQL_TEXAS__USER=root
SQL_TEXAS__PASS=******
SQL_TEXAS__DTBS=test
SQL_TEXAS__PORT=3306
SQL_TEXAS__CHAR=UTF8
```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/bb9ace83de4c40af24b36ae7905a0c82b17f50e69136cdeb68aad4e107d46c52?d=identicon)[AGrandesR](/maintainers/AGrandesR)

---

Top Contributors

[![AGrandesR](https://avatars.githubusercontent.com/u/61379065?v=4)](https://github.com/AGrandesR "AGrandesR (3 commits)")

### Embed Badge

![Health badge](/badges/agrandesr-sql-custom-action/health.svg)

```
[![Health](https://phpackages.com/badges/agrandesr-sql-custom-action/health.svg)](https://phpackages.com/packages/agrandesr-sql-custom-action)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
