hxgf/slime-utilities

Enhancement utilities for developing with Slim framework

1.2.0 2023-01-18 21:13 UTC

This package is auto-updated.

Last update: 2025-03-22 23:57:24 UTC


README

Abstraction functions to promote a fast and easy development workflow with Slim.

Most of these functions aren't specific to Slim and can be used in other contexts or on their own (except for the 'render' functions). We've bundled them together for convenience to be included with the Slime boilerplate and metaframework.

These functions are also available as separate packages:

Installation

composer require jyoungblood/slime-utilities
use Slime\render;
use Slime\db;
use Slime\http;
use Slime\cookie;
use Slime\x;

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

API

Refer to the source packages for usage examples.

render - Render Content as PSR-7

  • render::hbs($request, $response, $parameters)
  • render::redirect($request, $response, $parameters)
  • render::json($request, $response, $parameters)
  • render::lightncandy_html($parameters)($data)
  • render::initialize_handlebars_helpers()
  • render::twig($request, $response, $parameters)

db - Data Handlers (mysql w/ PDO)

  • db::init($settings)
  • db::insert($table, $input)
  • db::find($table, $criteria, $options)
  • db::update($table, $input, $criteria)
  • db::delete($table, $criteria)
  • db::create_placeholders($criteria)

http - HTTP Request Handlers

  • http::request($url, $parameters)
  • http::get($url, $parameters)
  • http::post($url, $parameters)
  • http::json($url, $parameters)

cookie - Cookie Handlers

  • cookie::set($key, $value, $parameters)
  • cookie::get($key)
  • cookie::delete($key)

x - Misc Utilities

  • x::email_send($parameters)
  • x::client_ip()
  • x::url_slug($string)
  • x::url_strip($url)
  • x::url_validate($url)
  • x::br2nl($string)
  • x::array_encode($array)
  • x::array_decode($string)
  • x::console_log($input, $parameters)
  • x::dd($input, $parameters)
  • x::file_write($input, $target_filename, $parameters)
  • x::error_log($input, $parameters)