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.
You can install the package via composer
composer require karriere/legacy
Place the initialize
call after session_start
and before helper usage:
\Karriere\Legacy\Bootstrap::initialize();
Dumps an arbitrary variable/value and stops execution of the script.
dd('any value');
dd($_GET);
Helper method for php session operations.
session();
Returns an instance of Karriere\Legacy\Session
.
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 the given key-value pair in the session.
session(['key' => 'value']);
Store a key-value pair only for the subsequent request.
session()->flash($key, $value);
Helper method for sending redirects.
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();
The redirector allows to store flash messages before sending the actual redirect.
redirect('http://www.karriere.at')->with('status', 'something happened')->send();
Apache License 2.0 Please see LICENSE for more information.