Symfony 6 + Doctrine - How to configure Doctrine\DBAL\Driver\OCI8\Middleware\InitializeSession? - oracle

The Doctrine\DBAL\Event\Listeners\OracleSessionInit was deprecated in DBAL 3.5 (https://github.com/doctrine/dbal/blob/3.5.x/UPGRADE.md) in favor of the Doctrine\DBAL\Driver\OCI8\Middleware\InitializeSession.
How should I setup the application with a new middleware? The documentation (https://symfony.com/bundles/DoctrineBundle/2.4.x/configuration.html#oracle-db) still show an old way.
I tried to use driver_class and wrapper_class options, but it does not work.

Related

Call to undefined function factory()

Environment: Laravel Framework Lumen (8.2.2) (Laravel Components ^8.0)
When I run
$blogs = factory('App\Blog', 2)->create();
in BlogsControllerTest.php, it shows
Call to undefined function factory()
As Laravel's upgrade guide says the Model factory was changed.
The new way is like this App\Models\Blog::factory()->count(3)->create();
To use old version referrer to documentation.
However, to ease the upgrade process, a new laravel/legacy-factories package has been created to continue using your existing factories with Laravel 8.x
To install it use composer composer require laravel/legacy-factories
Answering my own question in case it helps somebody.
It works this way too.
$blogs = BlogFactory::new()->count(2)->create();
ref: laravel.com/docs/8.x/database-testing#connecting-factories-and-models

Laravel 5.8 - Can't resolve instance from service container after update from 5.7 to 5.8

Laravel Version: 5.8.11
PHP Version: 7.1.26 (Homestead) - but also tested with 7.2 with same result
Since updating from 5.7 to 5.8, I can't resolve an instance anymore. It returns a string and I get Trying to get property of non-object.
Steps To Reproduce:
I bind the instance in a Middleware with:
$globals = new Globals();
app()->instance('App\Helpers\Globals', $globals);
$globals->brows_browser = Agent::browser();
when trying to resolve it later (for example in web.php) with:
$browser = resolve('App\Helpers\Globals')->brows_browser;
I get an error exception Trying to get property of non-object. $browser is a string "Helpers\Globals" and not an object. Was working fine in all Laravel versions before.
namespace App\Helpers;
class Globals
{
public $brows_browser;
public $brows_device;
public $brows_platform;
public $brows_version;
}
I also tried to bind the instance in the route (web.php) and it produced the same result.
When I look at resolve('App\Helpers\Globals'), it is a string "App\Helpers\Globals" and not an object.
Anyone any idea? Could this be a bug in L5.8?
thanks
UPDATE:
It is not a bug.
I have goetas-webservices/xsd2php-runtime installed with composer and that's causing problems. I really have no idea why and what to do about it though.
These are the dependencies installed. I'm a bit at a dead end as I need that package:
Package operations: 17 installs, 0 updates, 0 removals
- Installing jms/metadata (2.0.0): Loading from cache
- Installing hoa/exception (1.17.01.16): Loading from cache
- Installing hoa/event (1.17.01.13): Loading from cache
- Installing hoa/consistency (1.17.05.02): Loading from cache
- Installing hoa/zformat (1.17.01.10): Loading from cache
- Installing hoa/protocol (1.17.01.14): Loading from cache
- Installing hoa/iterator (2.17.01.10): Loading from cache
- Installing hoa/visitor (2.17.01.16): Loading from cache
- Installing hoa/ustring (4.17.01.16): Loading from cache
- Installing hoa/compiler (3.17.08.08): Loading from cache
- Installing hoa/regex (1.17.01.13): Loading from cache
- Installing hoa/math (1.17.05.16): Loading from cache
- Installing hoa/stream (1.17.02.21): Loading from cache
- Installing hoa/file (1.17.07.11): Loading from cache
- Installing doctrine/annotations (v1.6.1): Loading from cache
- Installing jms/serializer (2.2.0): Loading from cache
- Installing goetas-webservices/xsd2php-runtime (v0.2.9): Loading from cache
jms/serializer suggests installing doctrine/collections (Required if you like to use doctrine collection types as ArrayCollection.)
Writing lock file
UPDATE 2:
I drilled further down and it seems that hoa/compiler (specifically hoa/stream) is incompatible with Laravel 5.8
hoa/compiler is a dependency of jms/serializer.
That really sucks because jms/serializer is irreplaceable for us!
It's not a Laravel bug but an incompatibility with hoa/compiler (specifically hoa/stream).
hoa/compiler is a dependency of jms/serializer.
So for the moment jms/serializer won't play nice with Laravel 5.8
simple bind like this in laravel 5.8 take care will be registered within service providers,
$this->app->bind('App\Helpers\Globals', function () {
return new App\Helpers\Globals();
});
You may use the make
$globals = $this->app->make('App\Helpers\Globals');

Stripe api trigger a TLS error even with the right version of TLS

I'm trying to make a payment in my application (Laravel 5.4 + Vue on the front end) but stripe keeps returning this error:
(1/1) HttpException
Stripe no longer supports API requests made with TLS 1.0. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at https://stripe.com/blog/upgrading-tls.
The problem is that if I go to the support page and I copy and paste the script to check my TLS version:
<?php
// Include stripe-php as you usually do, either with composer as shown,
// or with a direct require, as commented out.
require_once("vendor/autoload.php");
// require_once("/path/to/stripe-php/init.php");
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
\Stripe\Stripe::$apiBase = "https://api-tls12.stripe.com";
try {
\Stripe\Charge::all();
echo "TLS 1.2 supported, no action required.";
} catch (\Stripe\Error\ApiConnection $e) {
echo "TLS 1.2 is not supported. You will need to upgrade your integration.";
}
?>
I get a "TLS 1.2 supported, no action required.". On top of that one week ago the api was working with no problem and in the online version is still working, but on local it does not.
What am I missing?
According to this, it should work if your version of Stripe PHP is greater than 3.19.0:
If you receive the message “TLS 1.2 is supported”, no changes need to be made. If not, check which version of our PHP library you are using. If it’s below 3.19.0, update it and try again. Otherwise, continue with these additional steps.

Symfony2 PHP 5.6 OpCode

We're using symfony2 with php 5.6.
With default config we can cache validation metadata:
framework:
validation:
cache: apc
How can we use this with PHP 5.6 and built in OpCache?
In default app.php we can cache the class autoloader:
if (extension_loaded('apc')) {
$apcLoader = new ApcClassLoader('foo', $loader);
$apcLoader->register(true);
}
How can we achieve the same using Zend OpCache? We tried with UniversalClassLoader but we are not shure, if this is right.
In default config we can use apc also for caching doctrine metadata, dql, and so on:
doctrine:
orm:
metadata_cache_driver: apc
result_cache_driver: apc
query_cache_driver: apc
Is there a way to cache metadata, result and query stuff with propel instead of Doctrine?
The Opcache built into recent PHP versions doesn't provide APC-like user storage - it's just for the bytecode caching. You can install ApcU, to use the APC cache driver, but otherwise, you'll want to select a different cache mechanism.
It won't be so much of an issue for the ClassLoader, since that is already handled by Composer optimisation and the Opcache, but will be useful for the other caching.

Routing error in Laravel 4.1 - Controller method not found

I've upgraded from Laravel 4 to Laravel 4.1 in a new branch on my repo, following the steps in
https://github.com/laravel/laravel/blob/develop/upgrade.md
The only step I wasn't able to fully follow was point 11 - add use Illuminate\Routing\Controller in baseController. The instruction is to replace an existing use statement. However in my version 4.0.9, it wasn't there.
Anyway, I am encountering a routing error when trying to hit a grouped route.
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
Controller method [audience/uk] not found.
I could hit the route without problems in the 4.0 branch.
I believe my upgrade went ok otherwise as I could correctly see the 4.1 changes in `artisan changes'
My route looks like this:
Route::group(array('prefix' => 'admin', 'before' => 'auth.basic'), function()
{
Route::get('upload/audience/uk',array('as' => 'get-upload-uk-audience', 'uses' => 'CSVController#getUKAudience'));
});
Any ideas?
Thanks
I came across the same problem using Laravel 4.1 which I solved by adding the following line right at the very top of the BaseContoller.
use Illuminate\Routing\Controller;
I'm also using Codesleeve Asset Pipline and had to add the same line to the top of the AssetPipelineController to get that working too.
I did quite an extensive search on this topic and was surprised at the lack of information online.
Hope this helps
I'm just going to avoid using Route::controller.
Ref: https://github.com/laravel/framework/pull/2850
Thanks #Anultro from the github irc channel

Resources