Using composer with symfony 1.4 - composer-php

I am trying to autoload composer-installed libraries with a Symfony 1.4 application but have some name conflict.
I have a legacy Symfony 1.4 application (in fact I am using a FriendsOfSymfony1/symfony1 1.5 clone that supports php 7.2).
I need to use AWS SDK PHP library.
In order to use it I need to install it with composer
I have added required components to composer.json, run composer update and modified my ProjectConfiguration:
require_once dirname(__FILE__) . '/../lib/vendor/autoload.php';
require_once dirname(__FILE__) . '/../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();
class ProjectConfiguration extends sfProjectConfiguration {
Symfony's autoload stopped working. I get a warning that actually is a critical error:
( ! ) Warning: constant(): Couldn't find constant Project::PEER in ***/lib/vendor/propel/propel1/runtime/lib/query/ModelCriteria.php on line 79
When I remove the line
require_once dirname(__FILE__) . '/../lib/vendor/autoload.php';
everything works fine (but, of course, I cannot see the composer installed packages).

Related

How to convert laravel 7.1.3 projects to run on laravel 8.0.0? [duplicate]

after updating my mac to php 8 laravel app stopped working, this is the error I'm getting:
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 871
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 945
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 871
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 945
I've tried to fix the issue by investigating the code with no luck
THE SOLUTION
As explained here latest version of laravel 6, 7 and 8 has made changes required for php 8. all you have to do is:
1- add php 8 to your composer.json (I've kept v7.4 just in case production server does not support php 8 yet)
"php": "^7.4|^8.0",
2- to run composer update to update your laravel to the latest version
composer update
3- make sure update the following libraries since they exist in all laravel applications
PHP to php:^8.0
Faker to fakerphp/faker:^1.9.1
PHPUnit to phpunit/phpunit:^9.3
4- check for any other library which needs to be updated, contribute if they haven't supported php 8. but you should be good to go with most of the libraries since they have active contributors.
EXPLAINING THE PROBLEM
as described here
PHP 8 introduces several improvements in PHP type systems such as the introduction of Union Types, mixed type, and a few more.
With these changes, certain methods in Reflection API's
ReflectionParameter yield incorrect results.
In PHP 8, the following methods from ReflectionParameter class is
deprecated:
ReflectionParameter::getClass()
ReflectionParameter::isArray()
ReflectionParameter::isCallable()
ReflectionParamter::getType() is the recommended way to replace the
deprecated methods. This method is available in PHP 7.0 and later.
Check your php version in your virtual machine(xampp or server).
php --version
Is that version PHP 8 ? Am I right? That's the cause of the problem:
PHP 8 introduces several improvements in PHP type systems such as the introduction of Union Types, mixed type, and a few more.
With these changes, certain methods in Reflection API's ReflectionParameter yield incorrect results.
In PHP 8, the following methods from ReflectionParameter class is deprecated:
ReflectionParameter::getClass()
ReflectionParameter::isArray()
ReflectionParameter::isCallable()
ReflectionParamter::getType()
Downgrade your php version to 7.4 and your Laravel app works like a charm!
I had similar issue. But I had already run brew update and brew cleanup before I noticed the issue. What I did:
I noticed this error from brew cleanup:
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
rm '/usr/local/bin/node'
To force the link and overwrite all conflicting files:
brew link --overwrite heroku-node
I ran the commands:
brew link --overwrite composer
composer upgrade
composer update
That's what worked for me
If you're using valet you should do the followings:
Downgrade from php8+ to php7.4 valet isolate php#7.4
Then run composer update using valet valet composer update

composer require yajra/laravel-oci8:^8 in laravel 8

PHP version 7.3.22
Running on Laravel Framework version 8
root#df77c47e6f1e:/var/www/oracle-laravel-v8# composer require yajra/laravel-oci8:^8
PHP Warning: PHP Startup: Unable to load dynamic library 'oci8_12c' (tried: /usr/lib/php/20180731/oci8_12c (/usr/lib/php/20180731/oci8_12c: cannot open shared object file: No such file or directory), /usr/lib/php/20180731/oci8_12c.so (/usr/lib/php/20180731/oci8_12c.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_oci' (tried: /usr/lib/php/20180731/pdo_oci (/usr/lib/php/20180731/pdo_oci: cannot open shared object file: No such file or directory), /usr/lib/php/20180731/pdo_oci.so (/usr/lib/php/20180731/pdo_oci.so: cannot open shared object file:
No such file or directory)) in Unknown on line 0
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2.0 is about to be released and the older 1.x releases will self-update directly to it once it is released. To avoid surprises update now to the latest 1.x version which will prompt you before self-updating to 2.x.
Run composer self update command and clear composer cache
composer self-update
Then
composer clear-cache
There is nothing wrong about laravel and composer here. It seems that your system's php installation/configuration is wrong (pdo_oci extension is missed or misconfigured) so it can't process anything, even fails at composer startup.
Composer itself is package manager written in php. And laravel is framework written in php. So it's laravel is running on php, not vice versa.

JpGraph on Windows via Composer - Class not found

I've installed PHPSpreadsheet and JpGraph via composer on a Windows machine. I'm using the following code but am getting the error "Class 'Graph' not found". Is there another way I need to be including JpGraph?
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph;
$graph = new Graph(400,300);
jpgraph/jpgraph package is outdated and abandoned.
Since version 1.25 PHPOffice/PhpSpreadsheet supports mitoteam/jpgraph package which is actual and has php 8.2
After installing both packages by composer you need to setup PhpSpreadsheet to use mitoteam/jpgraph as renderer:
\PhpOffice\PhpSpreadsheet\Settings::setChartRenderer(
\PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraphRenderer::class
);
Additional details:
https://github.com/PHPOffice/PhpSpreadsheet#chart-export
https://packagist.org/packages/mitoteam/jpgraph

Laravel Error on Logging

I just cloned a project of a colleague of mine.
Configured httpd. But when I go to the landing page I get:
FatalThrowableError in ConfigureLogging.php line 59:
Call to undefined method Illuminate\Foundation\Bootstrap\ConfigureLogging::configureHandler()
Laravel is 5.0. Does anyboy had the same issue?
EDIT
I solved this problem, because in config/app.php the variable 'log' was missing. But now:
Class 'Illuminate\Notifications\NotificationServiceProvider' not found
First, make sure that vendor/laravel/framework/src/Illuminate/Notifications/NotificationServiceProvider.php exists. If not, rm -r vendor; composer install.
Second, make sure that your autoload path is OK: In bootstrap/autoload.php, ensure that it says require __DIR__ . '/../vendor/autoload.php'; on line 17.
Third, dump all of your config cache: php artisan cache:clear.
Fourth, reinitialize the composer autoloader: composer dumpautoload.
Report back as to whether the problem is fixed or not.

what is the solution for php_mysql.dll ext in laravel with php 7 and IIs7

I am using laravel latest framework (5.3.*) with IIS7 and php7. It is showing a warning for create project or any artisan command like
c:\inetpub\wwwroot\test>php atisan serve PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files\PHP\ v7.0\ext\php_mysql.dll' - %1 is not a valid Win32 application. in Unknown on line 0
I want to create my project with latest version of php and laravel but with php7 the php_mysql.dll is deprecated. How can I prevent the warning of php_mysql.dll?
Did you copy php.ini from a previous installation of PHP 5.x? It looks like you have copied the extensions and php.ini from a previous installation of PHP 5, compiled with a different version of VC or 32/64bit.
To solve the issue, you should just need to open your php.ini, and comment out or remove the line:
extension=php_mysql.dll

Resources