Code Monkey home page Code Monkey logo

codeigniter-blade-theme-engine's Introduction

Codeigniter-Blade-Theme-Engine

This library integrates Laravel's Blad Engine into Codeigniter with a theming functionality so you are not only limited to displaying views in the traditional CI style but it gives you the power to have as many themes as you want in one CI installation and you can switch themes anytime and anywhere you want.

Installation

  1. Clone/Download this repository.
  2. Copy all files to your CodeIgniter folder.
  3. Open application/config/autoload.php
  4. Add theme to the following arrays
    $autoload['libraries'] = array('theme');
    $autoload['helper'] = array('theme','url');
    $autoload['config'] = array('theme');

Install Blade Package

We are using duncan3dc/blade which is a standalone package of Blade. So Install the said package via Composer by issuing this command

composer require duncan3dc/blade

Make sure you have Configured Using Composer with your CodeIgniter in config.php file

Configuration

  1. Create a Directory themes in your CodeIgniter's root directory
  2. You are free to Change the name of themes directory
  3. Create default directory in the themes directory
  4. Open application/config/theme.php
  5. You can see some Configuration items.
  6. If you have changed the name of themes directory, configure that in
    $config['theme_directory'] = FCPATH.'themes'.DIRECTORY_SEPARATOR;
  7. If you have changed the sub directory of themes from default to something else, Configure that in
    $config['theme_default'] = 'default';

Usage

In the application/config/theme.php file, You have configured the default theme name. Which will be used as your default directory where the library will look for views/template files.

Go to themes/default directory and create welcome.blade.php file.

Paste the following Text in that file.

<DOCTYPE html>
<html lang="en">
<head>
	<title>{{$page_title}} - CodeIgniter</title>	
</head>
<body>
<h1>Welcome {{$person_name}}!</h1>
</body>
</html>

Now in your controller, do the following

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Welcome extends CI_Controller {

	public function index()
	{
	    $view_data = array(
	        	'page_title' => 'Blade template Engine came to CodeIgniter',
			'person_name' => 'Fayaz Khan'
        	);
		$this->theme->display('welcome',$view_data);
	}
}

That's it, Navigate to /welcome and you will see the Blade template engine working the way you want,

Documentation

You can find usage and all documentation of Blade Template engine @ Laravel Official Website

Contribution, Feedback and suggestions

This is the initial version of blade theming engine. I am looking forward to see your feedback and suggestions. I will be adding more features to this library as I get free time.

Happy Coding

codeigniter-blade-theme-engine's People

Contributors

fayazk avatar

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.