yii2tech / illuminate Goto Github PK
View Code? Open in Web Editor NEWYii2 to Laravel Migration Package
License: Other
Yii2 to Laravel Migration Package
License: Other
I have been working with yii2 since 3 years now and there is a project which is very important and I have to migrate it for my client. I can convince him to migrate to larval but before that I would like to be very sure of that how I'm gonna plan everything.
Could you please provide basic yii2 template conversion code with laravel please?
It will be really helpful for me to continue with new framework and learn more about both yii2 and laravel.
Yii2 is something which I'm comfortable with and it's so robust that I can't deny the fact that it is still working fine and giving us a class performance.
But due to lack of latest modules I do have to move on.
Thanks
Error:
yii\base\InvalidConfigException: Unable to determine the request URI. in project/vendor/yiisoft/yii2/web/Request.php on line 1059
It looks like the $_SERVER['REQUEST_URI']
is empty after passing of the request to Yii2 side.
tests/Feature/ExampleTest.php
...
public function testBasicTest()
{
$response = $this->get('/');
$response->assertStatus(200);
}
...
If set $_SERVER['REQUEST_URI']
manually all works fine.
tests/TestCase.php
abstract class TestCase extends BaseTestCase
{
//use CreatesApplication;
public function createApplication()
{
$_SERVER['SCRIPT_FILENAME'] = dirname(__DIR__) . '/public/index.php';
$_SERVER['SCRIPT_NAME'] = '/index.php';
$_SERVER['REQUEST_URI'] = '/';
$app = require __DIR__ . '/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
}
Q | A |
---|---|
This Package Version | dev-master |
Laravel Framework Version | 6.18.19 |
Yii Framework Version | 2.0.35 |
PHP version | 7.4.7 |
Operating system | Ubuntu 18.04.4 LTS |
We are working on migration of very large project.
Is there any example how to use Yii2 console commands together with Laravel?
Register some bind:
public function register()
{
$this->app->bind(UserRepositoryInterface::class, UserRepository::class);
}
And try to access via Yii in some controller:
Yii::$container->get(UserRepositoryInterface::class);
Q | A |
---|---|
This Package Version | dev-master |
Laravel Framework Version | 6.16.0 |
Yii Framework Version | 2.0.32 |
PHP version | 7.2.24 |
Operating system | ubuntu 18.04.3 |
Why switch from Yii2 to Laravel?
It is sad to admit, but Yii is outdated technology, which does not keep up with the modern trends....
...
@klimov-paul I totally agree with you, and I am also thinking about the same migration question recently. What do you think of CakePHP as a migration option?
When sticking to the plan to refactoring:
Model -> Controller -> View
When refactoring a Model and set some flash message these messages not moved to the Yii2 side.
E.g.:
Refactoring LoginController and set some flash message(Laravel side), which should move to Yii2 and come up in its view.
protected function authenticated(Request $request, $user)
{
...
session()->flash("info", "Welcome!");
}
Is it possible to temporarily allow this movement?
Q | A |
---|---|
This Package Version | dev-master |
Laravel Framework Version | 6.16.0 |
Yii Framework Version | 2.0.32 |
PHP version | 7.2.24 |
Operating system | ubuntu 18.04.3 |
Hello,
I am planning transition from yii to laravel, and would like to ask:
How would you approach transition of a project originally written in the yii advanced template? We have three domains connected (backend, frontend and api) using the yii advanced template. Want to run it in laravel.
Thanks!
Lucas
We had to make tons of changes to make this bridge library work with even the starter kits of Yii2 and Laravel. Here, releasing the work as open source for other community members to benefit. They can use this kit as a starting point and port their code into this to base their migration. This acts as a starting point or another abstraction layout on top of this library.
Working repo (with known issues) that integrates Yii2 & Laravel starter kits
https://github.com/PearlThoughts/yii2-laravel-migration
Yii starter kit used: https://github.com/yii-starter-kit/yii2-starter-kit
Laravel starter kit used: https://github.com/rappasoft/laravel-boilerplate
No action is required on this ticket as it is merely to educate fellow community members.
Based: #5
From docs:
Heads up! usage of this component requires Yii application running within
\Illuminate\Session\Middleware\StartSession
middleware. Make sure it is running prior to\Yii2tech\Illuminate\Http\YiiApplicationMiddleware
one.
How exactly it should achieve it?
Is move it from $middlewareGroups['web']
to $middleware
and do some manipulation with $middlewarePriority
or ...?
My current Kernel.php
:
protected $middleware = [
\Illuminate\Session\Middleware\StartSession::class,
...
\Yii2tech\Illuminate\Http\YiiApplicationMiddleware::class,
];
protected $middlewareGroups = [
'web' => [
...
// \Illuminate\Session\Middleware\StartSession::class,
...
],
...
];
protected $middlewarePriority = [
\Illuminate\Session\Middleware\StartSession::class,
...
\Yii2tech\Illuminate\Http\YiiApplicationMiddleware::class,
];
I'm not sure if it's actually an issue with library but as I've drained out all my options I thought I would just drop the question here in case anyone else is experiencing the same issue.
I've been setting up the bridge for a legacy Yii application that I'm migrating to Laravel. Most of it seems to work but I'm running in some issues with output buffering. Where Yii is already sending output to the client causing the bridge / Laravel to throw a HeadersAlreadySentException
.
I couldn't find anything in the docs so I dove in the code hoping to find a solution or cause of the issue.
The application is using various Yii widgets that use echo on quite some places, views, classes etc. These all use PJAX for rendering while making ajax calls. Of course Yii2tech\Illuminate\Yii\Web\Response
class is not happy with that and throws the exception.
Patchin all occurrences in these libraries would be an endless job, and at some point it even breaks the Yii code base. So I reached to enabling output buffering but even with output buffering enabled (unlimited) the exception is being thrown anyway.
I was hoping that someone already ran into this issue and knows a way to work around this issue.
In this scenario it's using the GridView widget
Exception
yii\web\HeadersAlreadySentException: Headers already sent in /project/legacy/backend/views/tickets-in/index.php on line 58. in file /project/vendor/yii2tech/illuminate/src/Yii/Web/Response.php on line 148
#0 /project/vendor/yiisoft/yii2/web/Response.php(341): Yii2tech\Illuminate\Yii\Web\Response->sendHeaders()
#1 /project/vendor/yii2tech/illuminate/src/Yii/Web/Response.php(116): yii\web\Response->send()
#2 /project/vendor/yiisoft/yii2/base/Application.php(390): Yii2tech\Illuminate\Yii\Web\Response->send()
#3 /project/legacy/backend/web/index.php(18): yii\base\Application->run()
#4 /project/vendor/yii2tech/illuminate/src/Http/YiiApplicationMiddleware.php(226): require('/Users/jorenvan...')
#5 /project/vendor/yii2tech/illuminate/src/Http/YiiApplicationMiddleware.php(152): Yii2tech\Illuminate\Http\YiiApplicationMiddleware->runYii('/Users/jorenvan...')
#6 /project/app/Http/Middleware/YiiApplicationMiddleware.php(30): Yii2tech\Illuminate\Http\YiiApplicationMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure), 'legacy/backend/...')
#7 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\Http\Middleware\YiiApplicationMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#8 /project/app/Http/Middleware/DisableMySqlSrictMode.php(17): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#9 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\Http\Middleware\DisableMySqlSrictMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#10 /project/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#11 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#12 /project/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#13 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#14 /project/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#15 /project/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest(Object(Illuminate\Http\Request), Object(Illuminate\Session\Store), Object(Closure))
#16 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#17 /project/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#18 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#19 /project/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#20 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#21 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#22 /project/vendor/laravel/framework/src/Illuminate/Routing/Router.php(697): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#23 /project/vendor/laravel/framework/src/Illuminate/Routing/Router.php(672): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#24 /project/vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#25 /project/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#26 /project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(166): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#27 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#28 /project/vendor/livewire/livewire/src/DisableBrowserCache.php(19): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#29 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Livewire\DisableBrowserCache->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 /project/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#31 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 /project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure))
#35 /project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#36 /project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#37 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 /project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))
#42 /project/vendor/fruitcake/laravel-cors/src/HandleCors.php(38): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\Cors\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /project/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#45 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#46 /project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#47 /project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(141): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#48 /project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#49 /project/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#50 /project/server.php(21): require_once('/Users/jorenvan...')
#51 {main}
Q | A |
---|---|
This Package Version | 1.2.0 |
Laravel Framework Version | v8.61.0 |
Yii Framework Version | 2.0.45 |
PHP version | 8.0.17 |
Operating system | OSX & ubuntu |
// SiteController
public function actionAbout()
{
return view('pages.about');
}
i try to inegrate Yii in my laravel project i follow all your steps still it will give me this error
Illuminate\Contracts\Container\BindingResolutionException
Target [Illuminate\Contracts\View\Factory] is not instantiable.
// config/app.php
'providers' => ServiceProvider::defaultProviders()->merge([
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
Illuminate\View\ViewServiceProvider::class,
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
])->toArray(),
// app/providers/AppServiceProvider.php
use App\Services\MailChimp;
use App\Services\SubscriptionManager;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
$this->app->singleton(MailChimp::class, function ($app) {
$component = new MailChimp();
$component->apiKey = config('mailchimp.apiKey');
$component->apiSecret = config('mailchimp.apiSecret');
return $component;
});
$this->app->singleton(SubscriptionManager::class, function ($app) {
$component = new SubscriptionManager();
$component->trialPeriod = config('subscription.trialPeriod');
return $component;
});
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
//
}
}
please provide me the solution or tell me what mistake i did ? @klimov-paul
Uncomment:
'container' => [
'__class' => Yii2tech\Illuminate\Yii\Di\Container::class,
],
in config/yii.php
P.s.
The same thing I've got with cache:
Q | A |
---|---|
This Package Version | 1.1.0 |
Laravel Framework Version | 6.16.0 |
Yii Framework Version | 2.0.32 |
PHP version | PHP 7.2.24 |
Operating system | ubuntu 18.04.3 |
Added the following to backend/config/main.php
'cache' => Yii2tech\Illuminate\Yii\Caching\Cache::class,
Added the following to config/yii.php
'middleware' => [
'container' => [
'__class' => Yii2tech\Illuminate\Yii\Di\Container::class,
],
'logger' => [
'__class' => Yii2tech\Illuminate\Yii\Log\Logger::class,
],
],
App to run without PHP errors.
Yii2tech\Illuminate\Yii\Log\Logger::defaultIlluminateLogger(): Return value must be of type yii\log\Logger, Illuminate\Log\LogManager returned
ii2tech\Illuminate\Yii\Caching\Cache::defaultIlluminateCache(): Return value must be of type Illuminate\Contracts\Cache\Repository, Illuminate\Cache\CacheManager returned
App runs fine without these configurations.
Q | A |
---|---|
This Package Version | 1.2.1 |
Laravel Framework Version | 9.33.0 |
Yii Framework Version | 2.0.46 |
PHP version | 8.1 |
Operating system | Mac Monterey 12.2.1 |
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.