coreplex / core
A collection of core classes for the coreplex packages.
Installs: 1 364
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
Requires (Dev)
- illuminate/events: 5.0.*
- illuminate/session: 5.0.*
- illuminate/view: 5.0.*
- phpunit/phpunit: 4.8.*
This package is auto-updated.
Last update: 2025-01-20 03:33:59 UTC
README
A collection of core classes for the coreplex packages.
Installation
This package requires PHP 5.4+, and includes a Laravel 5 Service Provider.
We recommend installing the package through composer. You can either call composer require coreplex/core
in your
command line, or add the following to your composer.json
and then run either composer install
or composer update
to download the package.
"coreplex/core": "~0.1"
Laravel 5 Integration
To use the package with Laravel 5 firstly add the core service provider to the list of service providers in
app/config/app.php
.
'providers' => array( Coreplex\Core\CoreServiceProvider::class, );
The publish the config file by running php artisan vendor:publish
.
Using the Renderer
To get started with the renderer, firstly you need to initialise the class.
$renderer = new Coreplex\Core\Renderer\Renderer();
To access the renderer from laravel just access it via the IOC container by its contract or its alias.
public function __construct(Coreplex\Core\Contracts\Renderer $renderer) { $this->renderer = $renderer; } $renderer = app('coreplex.core.renderer');
Rendering Templates
To render a view to a string call the make
method on the renderer. You can also pass dynamic data to the view by
passing an array of key value pairs as a second parameter.
$view = $renderer->make('path/to/view.php'); $view = $renderer->make('path/to/view.php', ['foo' => 'bar']);
Using the Session
To get started with the session class with firstly need to initialise it.
$config = require('path/to/coreplex.php'); $session = new Coreplex\Core\Session\Native($config);
Or with laravel just resolve it from the IOC container.
public function __construct(Coreplex\Core\Contracts\Session $session) { $this->session = $session; } $session = app('coreplex.core.session');
Add Item
To add an item to the session use the put
method.
$session->put('foo', 'bar');
Or to flash an value for the next request use the flash
method.
$session->flash('foo', 'bar');
Getting Items
To get an item from the session use the get
method.
$session->get('foo');
You may also want to check if an item exists in the session; to do so use the has
method.
$session->has('foo');
Removing Items
To remove an item from the session use the forget
method.
$session->forget('foo');