Code Monkey home page Code Monkey logo

core's Introduction

Core Build Status Latest Stable Version License

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');

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.