S.M_Emamian
S.M_Emamian

Reputation: 17383

combine codeigniter and laravel

I'm using codeigniter framework but I want to use features of laravel framework like below code that I can print a variable without <?php echo $name ?> :

Hello {{ $name }}

How can I do ?

Upvotes: 3

Views: 2816

Answers (3)

Aidid Alam
Aidid Alam

Reputation: 151

You can use BladeView library for CI.

class Welcome extends CI_Controller {
  public function __construct() {
    parent::__construct();
    $this->load->library("bladeview");
  }

 public function renderView(){
    $data=array(
            "name"=>"Jhon",
            "age"=>21
        );
    $this->bladeview->render("test", $data);
 }

 public function renderString(){
    $data=array(
            "name"=>"Jhon",
            "age"=>21
        );
    $string="Hello I'm \{{$name}}. My age is \{{$age}}";
    $this->bladeview->render($string, $data,false);
  }
}

then in view.blade.php you can render like you do in laravel blade.

Hello my name is {{$name}}. My Age is {{$age}}.

Output:

Hello my name is Jhon. My Age is 21.

Upvotes: 0

shubham Gautam
shubham Gautam

Reputation: 1

Yes! you can use blade template engine and use some laravel syntax {{$Data}} like this.....

1 allow vendor 2 install blade package 3 use it

Upvotes: 0

Abdulla Nilam
Abdulla Nilam

Reputation: 38584

Codeigniter is an Php Framework. And Laravel is also php framework too. And this both is not equal with each other. As simple

Codeigniter(<4.0) != Laravel

Take look at Laravel vs. CodeIgniter

Laravel vs. Codeigniter

    Module               Laravel                Codeigniter
----------------------------------------------------------
Layout Control              Yes                         No
ORM                         Yes                         No
Error Stack Trace           Yes                         No
Class Auto Loading          Yes                         Yes
–Database mySQL             Yes                         Yes
–Database SQLite            Yes                         Yes
–Database MSSQL             Yes                         Yes
–Database PostgreSQL        Yes                         Yes
–Database Cubrid            Yes                         Yes
–ODBC drivers               Yes                         No
–Database MariaDB           No                          No
Authentication Library      Yes                         No
External Modules            Yes                         Yes
Form Validation Rules       Yes                         Yes
Internationalization        Yes                         Yes
Database Module             Object-oriented             Hybrid Object-relational
Template language           Blade Template Engine       Blade php Proprietary
Design pattern              Active-Record               Active-Record
                            Model-View-Controller       Model-View-Controller
                            Dependency injection
                            Observer
                            Singleton
                            Event-Driven
                            MTV
                            Factory
                            RESTfull
                            Facade

So some open source library's can use with both of this frameworks but not all(phpMailer, phpExcel..)

Upvotes: 4

Related Questions