Package Data | |
---|---|
Maintainer Username: | neo79a |
Maintainer Contact: | schwinger@dbphp.de (Andreas Schwinger) |
Package Create Date: | 2015-10-15 |
Package Last Update: | 2017-12-11 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-01-12 15:01:04 |
Package Statistics | |
---|---|
Total Downloads: | 106 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 2 |
Total Forks: | 3 |
Total Open Issues: | 2 |
CodeigniterMigration is a package to integrate an already started Codeigniter-Session in Laravel 5.
The package includes ServiceProvider and Facade for easy Laravel integration. This is particularly useful if you want to slowly migrate legacy code to laravel and Codeigniter is still responsible for the Login & Authentication. You can read out the Userdata-Values of the current Codeigniter-session (via cookie-handling).
Require this package with composer:
composer require ci2lara/codeigniter_migration
After updating composer (composer update), add the ServiceProvider to the providers array in config/app.php
In your app config, add the CodeigniterServiceProvider
to the providers array.
'providers' => [
...
'Ci2Lara\Codeigniter_Migration\Providers\CodeigniterServiceProvider',
...
];
You have to use the facade, add it to the aliases array in your app config
'aliases' => [
...
'CodeigniterSession' => 'Ci2Lara\Codeigniter_Migration\Facades\CodeigniterSession',
...
];
Copy the package config to your local config with the publish command:
php artisan vendor:publish
To change the configuration, uncomment the values (e.g. sess_table_name or sess_cookie_name) in the new config/ci_session.php
You should only use unencrypted cookies in codeigniter - so Laravel can directly access to the cookie. Because of security-reasons you have to allow Laravel to use this unencrypted Cookie.
Change the following Line in your app/Http/Kernel.php in the "$middleware"-Array
'Illuminate\Cookie\Middleware\EncryptCookies'
to
'Ci2Lara\Codeigniter_Migration\Middleware\EncryptCookies'
The Package-Middleware only disable the Cookie-Encryption for the configured Cookie-Name only (Default: ci_session, see config/ci_session.php)
Shortly: CodeigniterSession::getUserData()
e.g.
\View::share('userdata', CodeigniterSession::getUserData());
You can expand your CI-Code
e.g. in your CodeIgniter-Login-Handling
$userdata['ci_config'] = array('version' => '1.0', 'module_xy_enabled' => $this->config->item('modul_xy_enabled'), 'yourconfig' => 'some value');
$CI->session->set_userdata($userdata);
In Laravel you can simply access with the following code:
CodeigniterSession::getConfigData()->version
Try it out
dd(CodeigniterSession::getConfigData());
Contributions to the CodeigniterMigration are welcome. Please note the following guidelines before submiting your pull request.
CodeigniterMigration is licensed under the MIT License.
Copyright 2015 [Andreas Schwinger]