karriere/legacy

This package is abandoned and no longer maintained. No replacement package was suggested.

v1.0.0 2017-02-28 07:10 UTC

This package is auto-updated.

Last update: 2020-03-25 07:46:51 UTC


README

687474703a2f2f7777772e6b617272696572652e61742f696d616765732f6c61796f75742f6b61746c6f676f2e737667     StyleCI

Legacy Helpers

This package contains some convenient helper functions inspired by laravel helpers that can be used in a legacy application without IoC.

Tasks like sending a redirect or working with the session can be a real mess in plain php. Therefore this package provides helper functions to help with these problems.

Installation

You can install the package via composer

composer require karriere/legacy

Bootstrapping

Place the initialize call after session_start and before helper usage:

\Karriere\Legacy\Bootstrap::initialize();

Available Helpers

die dump

Dumps an arbitrary variable/value and stops execution of the script.

dd('any value');
dd($_GET);

session

Helper method for php session operations.

get session instance

session();

Returns an instance of Karriere\Legacy\Session.

get session value

Retrieve a value from the session, the call allows a second parameter that is returned as default value if no session data is found for the eky

session('key');
session('key', 'no data');

store data in session

Store the given key-value pair in the session.

session(['key' => 'value']);

add flash message

Store a key-value pair only for the subsequent request.

session()->flash($key, $value);

Redirect

Helper method for sending redirects.

send redirect

The method allows a second parameter for status code, the default value is 302 (Found - Moved Temporarily).

redirect('http://www.karriere.at')->send();
redirect('http://www.karriere.at', 301)->send();

redirect with flash message

The redirector allows to store flash messages before sending the actual redirect.

redirect('http://www.karriere.at')->with('status', 'something happened')->send();

License

Apache License 2.0 Please see LICENSE for more information.