Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

karriereat/legacy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

    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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages