Global helper functions for the Codemonster PHP ecosystem.

Installs: 73

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/codemonster-ru/support

v1.3.0 2025-12-09 13:54 UTC

This package is auto-updated.

Last update: 2025-12-09 14:07:27 UTC


README

Latest Version on Packagist Total Downloads License Tests

Global helper functions for the Codemonster PHP ecosystem.

📦 Installation

composer require codemonster-ru/support

🧩 Provided Helpers

Function Description
config() Get or set configuration values
env() Read environment variables
view() / render() Render or return a view instance
router() / route() Access router instance
request() Get the current HTTP request
response() Create a new HTTP response
json() Return a JSON response
abort() Throw an HTTP-like exception
session() Read or write session data
db() Get a database connection (if installed)
schema() Schema builder (if database package present)
transaction() Run a DB transaction
dump() / dd() Debugging utilities

These helpers are framework‑agnostic and automatically enabled when installed.

🚀 Usage

<?php

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

// ENV
$env = env('APP_ENV', 'production');

// Config
config(['app.name' => 'Codemonster']);
echo config('app.name');

// Requests & Responses
$request = request();
return response('Hello World', 200);

// Router
router()->get('/', fn() => response('Home'));

// Views
echo render('emails.welcome', ['user' => 'Vasya']);

// Debug
dump($request);
dd('Bye!');

🗄 Database Helpers (optional)

If codemonster-ru/database is installed:

$conn = db();         // default connection
$conn = db('mysql');  // named connection

schema()->create('users', function ($table) {
    $table->id();
    $table->string('name');
});

transaction(function ($db) {
    $db->table('logs')->insert(['msg' => 'ok']);
});

🧪 Testing

composer test

👨‍💻 Author

Kirill Kolesnikov

📜 License

MIT