Twig loader crushes with October CMS - php

When I start fresh october project it says:
Class System\Twig\Loader contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Twig_LoaderInterface::getSourceContext) /home/doctor/web/paintshop/modules/system/twig/Loader.php line 82
Did anyone faced such problem? My php version is 7, and php7 mod is enabled in apache, while php 5.6 mod is disabled. Thank you!

Most of cases if you have a fresh OctoberCMS install it won't be the latest update.
Go to Config/Cms.php and set edgeUpdates to true and try to update the application from backend.

If you still have problems, you can try to switch to pulling from the dev branch instead by setting the require property of your composer.json to the dev branch for the library and then running composer update
"require": {
"php": ">=5.5.9",
"october/rain": "dev-develop",
"october/system": "dev-develop",
"october/backend": "dev-develop",
"october/cms": "dev-develop",
"laravel/framework": "5.1.*",
"wikimedia/composer-merge-plugin": "dev-master",
"guzzlehttp/guzzle": "^6.2"
},
The reason for the problem is that the Twig dependency in the OctoberCMS Library composer.json was recently updated to include v2.0 which the library doesn't officially support yet as Twig v2 doesn't support below PHP 7 while October does still. The reversion back to just Twig v1.30 was just made a couple of hours ago, hence why you might need to update from the dev branch of the library to pull your changes.

Related

What is usage of "conflict" in composer.json and what should I do with it?

I found the composer.json & composer.lock(php) has conflict section (not to be confused with merge conflict ). The other similar files like package.json/yarn.json (nodejs) or Pipfile (python) and the corresponding lock files package-lock.json/yarn.lock or Pipfile.lock, do not have such format even though all these lock files serve the same purpose (lock the dependence to the exact version) and implement in the similar way (at least looking from the surface)
So what is usage of it and what should I do with it ? I read the composer document https://getcomposer.org/doc/04-schema.md#conflict but I still feel confused, e.g.
Map of packages that conflict with this version of this package. They will not be allowed to be installed together with your package.
For example after running composer install I have a composer.lock saying
{
"name": "symfony/http-kernel",
"version": "v4.4.20",
...
"conflict": {
"symfony/browser-kit": "<4.3",
"symfony/config": "<3.4",
"symfony/console": ">=5",
"symfony/dependency-injection": "<4.3",
"symfony/translation": "<4.2",
"twig/twig": "<1.43|<2.13,>=2"
},
...
It is easy to guess "symfony/console" 5.0 is conflicted with "symfony/http-kernel" 4.4.20 so symfony/console 5.0 will not be installed.
Do I need to do anything with the conflict ? So far I feel like that as a package user (not the package developer) those info is just a FYI and I don't need to do anything. But then why bother to list them for me ? After all package.json and Pipefile don't have such information and I don't find the problem without it.
--- update ---
From the answer I got I realize I need to emphasize this: I understand composer.lock is for composer so I don't need to worry about it.
What I don't understand is the purpose putting it in composer.json, this file is for human users. So if it has a conflict section what should I do about it?
I want to know a practical use case of "conflict" section in my composer.json if I am not a package developer but a package user.
When building an application, you are free to choose your dependencies way better than when you are building a reusable library like symfony/http-kernel which you've mentioned in your question.
Putting any other package constraint in the conflict section of such a package means: if you want to install the package in the current version, no other package version must be installed that is listed in the conflict section. From your example: symfony/http-kernel in v4.4.20 must not be installed if symfony/browser-kit is installed in any version <4.3.
In your own application, you have more freedom to use stricter constraints for the packages you use. You could require all packages with pretty strict version numbers, but this makes updates less comfortable. For example, this is a part of the require section in one of my current projects:
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.2",
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^2.7",
"easycorp/easyadmin-bundle": "^3.1",
"exercise/htmlpurifier-bundle": "^3.1",
"knplabs/knp-snappy-bundle": "^1.8",
"league/csv": "^9.6",
"lexik/jwt-authentication-bundle": "^2.10",
"nelmio/cors-bundle": "^2.1",
All these packages might install tons of other dependencies which I cannot control. But if I know that any version of the other dependencies causes trouble, I can list them in the conflict section of my application such that this version is not installed.
For example, in the past I've needed that for an update of doctrine/migrations where the configuration has changed. I wanted to be able to update all packages except this one, because I didn't want to bother with the configuration changes I had to apply to my application for a while.
"conflict": {
"symfony/console": ">=5",
this means that for some reason your package can't work with symfony/console version 5 and higher, so it will keep it below 5.
E.g. you can exclude some package faulty version:
"conflict": {
"foo/bar": "1.420.69",
}
I know this is an old post, but thought I'd add a point to what's already been said:
You may still benefit from a conflict section in composer.json if you know any of your code conflicts with any packages. It could be any reason from both your code and the package trying to do similar jobs and stepping on each other's toes or simply that a package is badly written and breaks your code.
In that case, you can add a conflict section in your composer.json to tell composer to never download that package (or some releases of it).
This would be useful if you work with other developers and someone else might try to require that package, or if you worry that composer may try to install it as a dependency of yet another package e.g. X is the package you don't want, but another package Y depends on X and you don't know. Without the conflict section, composer would download package X without you even knowing/noticing.

How to configure symfony check:requirements?

I am using Symfony for an application. This application needs particulars PHP extensions to work, such as PHP GD, which are not listed in the base Symfony requirements.
I would like to know if it's possible to kind of edit the base list of requirements to add those extensions for my application to have them listed under the symfony check:requirements console output.
This requirements will NOT be tested when you launch symfony check:requirements, because this command doesn't depend of your application, it only checks the capacity to use symfony on the server.
This command will always return the same result, even if you launch it in a directory where there is no composer.yaml file.
But, you can add the needed extension by updating the composer.json file:
...
"require": {
"php": "^7.2",
...
"ext-gd": "*",
"ext-json": "*",
...
"foo/bar-bundle": "^1.3",
...
}
So, if the GD extension isn't installed on your server, installation of your application will not start.

Unable to install symfony/console:3.2 via composer and flex

I have a Symfony 4 project and am trying to install this package for working with AWS DynamoDB.
When I run composer require oasis/dynamodb-odm I get an error saying oasis/dynamodb-odm v0.5.3 requires symfony/console ^3.2 -> no matching package found. Attempting to run composer require symfony/console:^3.2 also results in the "Could not find package..." error.
As I am using Symfony 4, composer commands are intercepted by Symfony Flex and some extra stuff happens. Interestingly, there is a Flex recipe for symfony/console:3.3 but not 3.2 which I imagine might be the problem.
My understanding of the caret is that it should allow minor version bumps, so I wonder why console v3.3 is not installed instead.
I would like to use this package, and there aren't many DynamoDB PHP offerings out there, so how can I resolve this issue?
if you checkout the composer.json file of the package, you can see the following
"require" : {
"php" : ">=5.6",
"doctrine/annotations": "^1.4",
"oasis/aws-wrappers" : "^2.10",
"oasis/logging" : "^1.0",
"doctrine/common" : "^2.7",
"symfony/console" : "^3.2",
"symfony/finder" : "^3.2"
},
meaning it is compatible with symfony3 only.
Probably you can fork the repo and try changing the version numbers and test it. If it works you can install it.

Call not found in laravel Vinkla\Instagram package

I am getting this error while using the Vinkla\Instagram package for instafeed Class 'Vinkla\Instagram\InstagramServiceProvider' not found.
"require: {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"illuminate/html": "5.*",
"spatie/laravel-analytics": "^1.2"**
}
Seems that you are using the php 5.* and that's why composer pulling the 1.2 version of the package which has different class.
I got the same problem a month ago
The read me file that you read to setup package is for 2.4 version which is for php 7.0
Just update your php 5.* to php 7.* or get the read me file of 1.2 version of package to setup package correctly
I've written an article about this on my blog: Class not found error due to php version mismatch

Loading a composer package into Laravel 5

Solved: I've added the php and illuminate/support packages into my package composer.json file and it started working. I've got no idea why though so if someone could explain, I would really appreciate it.
"require": {
"php": ">=5.4.0",
"illuminate/support": "~5.0"
},
I've created a composer package for Laravel 5 which should generate models based on an existing database schema. However i'm unable to load it in.
I add my Command class into the app/Console/Kernel.php
'Iber\Generator\Commands\MakeModelsCommand'
But then I get the following error:
Class Iber\Generator\Commands\MakeModelsCommand does not exist
I'm really new to Laravel and I'm not sure why this is happening since composer generates the autoloader file just fine. I've created and added (into config/app.php) a Service Provider but that doesn't get resolved either. Not sure what I'm doing wrong.
Here's the package:
https://github.com/ignasbernotas/laravel-model-generator
Apparently adding the required attribute with the following packages solved the issue. I'm still not sure why.
"require": {
"php": ">=5.4.0",
"illuminate/support": "~5.0"
},

Categories