I'm new to silex, and I've got a file that creates a few defines. This is its content:
<?php
namespace Config;
define('DS',DIRECTORY_SEPARATOR);
define('ROOT',realpath(__DIR__ . '/../..'));
define('CONFIG',ROOT.DS.'app'.DS.'config');
I'm trying to load it using my composer.json:
{
"require": {
"silex/silex": "~2.0",
"twig/twig": "^1.33",
"doctrine/dbal": "^2.5",
"symfony/twig-bridge": "^3.2",
"boxedcode/silex-knp-menu-service-provider": "^1.0",
"symfony/form": "^3.2",
"symfony/validator": "^3.2",
"symfony/config": "^3.2"
},
"autoload": {
"psr-4": {
"Models\\": "src/MyApp/Models/",
"Config\\": "src/MyApp/Config/"
}
}
}
The defines file is inside src/MyApp/Config/, so I therefore hoped this line would be enough to load the defines file in my index.php file:
use Config\Defines;
But... it seems not... Can anyone tell me how to load the defines file so that I can use my Config class again?
Related
I want to use Bcrypt of Laminas-Crypt package in one of my files. After running
composer require laminas/laminas-crypt,
composer dump-autoload,
composer update
I declared a use statement in my controller:
use Laminas\Crypt\Password\Bcrypt;
The application loaded without any errors, but as far as I am concerned, all namespaces should be registered in config/modules.config.php for the autoloader to load the namespaces accordingly. After adding Laminas\Crypt namespace to the folder the application threw an exception:
Uncaught Laminas\ModuleManager\Exception\RuntimeException: Module (Laminas\Crypt) could not be initialized. in C:\xampp\htdocs\phpLessons\Shortly\vendor\laminas\laminas-modulemanager\src\ModuleManager.php:180
My question is:
Can the application function properly without the namespace of the used package being defined in the config/modules.config.php of root directory?
How can the exception be handled?
Edit:
Here is the relevant part of composer.json
"require": {
"php": ">=8.1.0",
"laminas/laminas-component-installer": "^3.0",
"laminas/laminas-development-mode": "^3.2",
"laminas/laminas-skeleton-installer": "^1.0",
"laminas/laminas-mvc": "^3.3.4",
"laminas/laminas-db": "^2.12.0",
"laminas/laminas-mvc-form": "^2.0.0",
"laminas/laminas-json": "^3.2",
"laminas/laminas-log": "^2.13.1",
"laminas/laminas-cli": "^1.1.1",
"laminas/laminas-mvc-i18n": "^1.2.0",
"laminas/laminas-mvc-plugins": "^1.1.0",
"laminas/laminas-mvc-middleware": "^2.0.0",
"laminas/laminas-session": "^2.10.0",
"laminas/laminas-di": "^3.2.2",
"laminas/laminas-view": "^2.25",
"laminas/laminas-form": "3.7",
"laminas/laminas-crypt": "^3.9",
"ext-pdo": "*",
"laminas/laminas-mail": "^2.20",
"doctrine/orm": "^2.14",
"doctrine/dbal": "^3.2",
"symfony/yaml": "^5.4",
"symfony/cache": "^5.4",
"doctrine/common": "^3.4",
"doctrine/doctrine-orm-module": "^5.3"
},
and modules.config.php from config/autoload:
return [
'Laminas\Cache',
'Laminas\Paginator',
'Laminas\Mail',
'Laminas\Mvc\Plugin\FilePrg',
'Laminas\Mvc\Plugin\FlashMessenger',
'Laminas\Mvc\Plugin\Identity',
'Laminas\Mvc\Plugin\Prg',
'Laminas\Session',
'Laminas\Mvc\Middleware',
'Laminas\Mvc\I18n',
'Laminas\Form',
'Laminas\I18n',
'Laminas\Log',
'Laminas\InputFilter',
'Laminas\Filter',
'Laminas\Hydrator',
'Laminas\Di',
'Laminas\Db',
'Laminas\Router',
'Laminas\Validator',
'Laminas\DeveloperTools',
'Laminas\Diactoros',
'DoctrineModule',
'DoctrineORMModule',
'Application',
'User',
'Pages',
];
I just installed fresh Symfony framework skeleton with annotations and Doctrine and it not works. I have got an error
Argument 1 passed to Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DoctrineParamConverter::__construct()
must be an instance of Doctrine\Common\Persistence\ManagerRegistry or null,
instance of Doctrine\Bundle\DoctrineBundle\Registry given, called in
my composer file
{
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.11",
"doctrine/doctrine-bundle": "^2.1",
"doctrine/doctrine-migrations-bundle": "^2.2",
"doctrine/orm": "^2.7",
"sensio/framework-extra-bundle": "^5.5",
"symfony/console": "4.4.*",
"symfony/dotenv": "4.4.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "4.4.*",
"symfony/yaml": "4.4.*"
},
"require-dev": {
"symfony/web-server-bundle": "4.4.*"
},
Please help.
I got the exact same problem today after installing the new symfony binary, composer update worked for me.
I have added to the config/packages/sensio_framework_extra.yaml
this lines and it working
sensio_framework_extra:
router:
annotations: false
request:
converters: true
disable: ['doctrine.orm']
I recently updated Symfony to 4.4 (from 4.3) and can't have my translations files updated automatically (using php bin/console tran:up --force) any more. The error that pops up is:
In body.html.twig line 1:
Unknown "inky_to_html" filter.
The file in question is vendor/symfony/twig-bridge/Resources/views/Email/zurb_2/notification/body.html.twig which I never use, I have no idea why it's inclued all at a sudden. To get rid of the message I tried to require twig/inky-extra but that requires the ext-xsl-extension and I don't really want to bloat my code with things I don't need just to get rid of an error related to a twig-extension that's also not needed.
I tried to change the version of the translation-interface as described here, but that also didn't change anything.
I guess it has something to do with my project as I couldn't find any similar problem, but I can't figure it out, so any help is appreciated.
EDIT:
Here's my composer.json, it's basically the same as it was generated when creating the Symfony 4.3-project, I only changed the version names to upgrade as described in the docs and ran composer update.
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"ext-intl": "*",
"apy/breadcrumbtrail-bundle": "^1.5",
"craue/config-bundle": "^2.3",
"easycorp/easy-log-handler": "^1.0",
"friendsofsymfony/jsrouting-bundle": "^2.4",
"league/csv": "^9.4",
"nesbot/carbon": "^2.25",
"sensio/framework-extra-bundle": "^5.1",
"sg/datatablesbundle": "^1.1",
"symfony/apache-pack": "^1.0",
"symfony/asset": "^4.0",
"symfony/console": "^4.0",
"symfony/dotenv": "^4.0",
"symfony/expression-language": "^4.0",
"symfony/flex": "^1.3.1",
"symfony/form": "^4.0",
"symfony/framework-bundle": "^4.0",
"symfony/http-client": "^4.0",
"symfony/intl": "^4.0",
"symfony/monolog-bundle": "^3.1",
"symfony/orm-pack": "*",
"symfony/process": "^4.0",
"symfony/security-bundle": "^4.0",
"symfony/security-csrf": "^4.0",
"symfony/serializer-pack": "*",
"symfony/swiftmailer-bundle": "^3.1",
"symfony/translation": "^4.0",
"symfony/twig-bundle": "^4.0",
"symfony/validator": "^4.0",
"symfony/web-link": "^4.0",
"symfony/yaml": "^4.0",
"tetranz/select2entity-bundle": "^3.0"
},
"require-dev": {
"dama/doctrine-test-bundle": "^6.1",
"doctrine/doctrine-fixtures-bundle": "^3.2",
"pdepend/pdepend": "^2.5",
"phpmd/phpmd": "^2.7",
"phpunit/php-code-coverage": "^7.0",
"roave/security-advisories": "dev-master",
"squizlabs/php_codesniffer": "3.*",
"symfony/debug-pack": "*",
"symfony/maker-bundle": "^1.0",
"symfony/phpunit-bridge": "^4.3",
"symfony/profiler-pack": "*",
"symfony/test-pack": "*",
"symfony/web-server-bundle": "^4.0"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts"
],
"post-update-cmd": [
"#auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.4.*"
}
}
}
symfony/twig-bridge:4.4 changed the dev requirements to require twig/inky-extra and also added the new Resources/views/Email template files that utilize the inky_to_html filter, that were not included in 4.3.
Since tran:up attempts to scan files within the <Bundle>/Resources/views directories of each bundle for translations, to circumvent the issue and avoid scanning the twig-bridge views, you should be able to specify the bundle name you want to update the translations of.
php bin/console tran:up <locale> <bundle or directory>
Outside of including the dev requirements to circumvent the issue, you would need to revert to symfony/symfony:4.3 to get rid of the new twig-bridge/Resources/views/Email directory.
Since you are using symfony/symfony:4.4 it requires the corresponding twig-bridge.
symfony/symfony:4.4 require [sic]
"symfony/twig-bridge": "self.version"
symfony/twig-bridge:4.4 require-dev [sic]
"twig/cssinliner-extra": "^2.12",
"twig/inky-extra": "^2.12",
"twig/markdown-extra": "^2.12"
Ultimately it appears to be a bug with the dev dependencies that should be reported to Symfony.
Update: A patch has been issued for version 3.4+, see: Fix the translation commands when a template contains a syntax error #34711
I have a new error after upgrading, that should not be related to the upgrade.
I am using SendInBlue Php Library in my project, loaded in my composer with :
"sendinblue/api-v3-sdk": "*#dev",
Used in my Service with:
use SendinBlue\Client\Api\SMTPApi;
use SendinBlue\Client\Model\SendEmail;
Called with :
$api_instance = new SMTPApi();
Since the upgrade I have a new error:
Attempted to load class "SMTPApi" from namespace "SendinBlue\Client\Api".
Did you forget a "use" statement for another namespace?
I tried clear cache, have rm -rf remove cache, Invalidate my phpStorm Cache + Restart, remove the two USE statement, and then look what is displayed when I try to create a new instance, but it's still the same USE statement that is added.
If I COMMAND+CLICK on the class called, it does show the related class (SMTPApi).
I am totally lost on what could be the problem here, is it symfony upgrade related ? Is it composer update that changed other things ?
for more information, here is the header of my Service:
namespace App\Services;
use FOS\UserBundle\Mailer\MailerInterface;
use FOS\UserBundle\Model\UserInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\Router;
use SendinBlue\Client\Api\SMTPApi;
use SendinBlue\Client\Model\SendEmail;
And here is my composer:
{ [...]
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"aws/aws-sdk-php": "^3.69",
"beelab/tag-bundle": "^1.4.0",
"friendsofsymfony/user-bundle": "^2.1",
"google/apiclient": "^2.0",
"gumlet/php-image-resize": "^1.9",
"kunalvarma05/dropbox-php-sdk": "^0.2.1",
"lildude/phpsmug": "^4.0",
"sendinblue/api-v3-sdk": "*#dev",
"sensio/framework-extra-bundle": "^5.1",
"sensiolabs/security-checker": "^4.1",
"symfony/apache-pack": "^1.0",
"symfony/asset": "^4.2",
"symfony/console": "^4.2",
"symfony/debug-pack": "^1.0",
"symfony/dependency-injection": "^4.2",
"symfony/dotenv": "^4.2",
"symfony/flex": "^1.0",
"symfony/form": "^4.2",
"symfony/framework-bundle": "^4.2",
"symfony/lock": "^4.2",
"symfony/maker-bundle": "^1.4",
"symfony/monolog-bundle": "^3.3",
"symfony/orm-pack": "^1.0",
"symfony/swiftmailer-bundle": "^3.0",
"symfony/translation": "^4.2",
"symfony/twig-bundle": "4.2",
"symfony/web-server-bundle": "^4.2",
"symfony/yaml": "^4.2"
},
"require-dev": {
"easycorp/easy-log-handler": "^1.0.2",
"symfony/debug-bundle": "^3.3|^4.2",
"symfony/profiler-pack": "^1.0",
"symfony/var-dumper": "^3.3|^4.2"
},
[...]
}
As said up here, needed to revert the library. Maybe now it's fixed by the creator on GIT.
I get the following error when executing Behat:
PHP Fatal error: Class 'Symfony\Component\Process\PhpExecutableFinder' not found
I don't know if its normal, but the PhpExecutableFinder is located within my composer.phar after php composer.phar update is called.
{
"require": {
"php": ">=5.4",
"ext-mcrypt": "*",
"slim/slim": "~2.0",
"slim/views": "0.1.*",
"twig/twig": "1.18.*",
"propel/propel": "~2.0#dev",
"zeflasher/propel2-geocodable-behavior": "dev-master",
"behat/behat": "3.0.*#stable",
"behat/mink": "1.6.*#stable",
"behat/mink-extension": "#stable",
"behat/mink-goutte-driver": "#stable",
"behat/mink-selenium2-driver": "#stable",
"peridot-php/leo": "~1.0"
},
"autoload": {
"classmap": ["website/", "vendor/"]
}
}
Is my current composer.json. Can anybody reproduce it? composer.phar is self-updated.
composer require symfony/process
That solved the issue. I don't know why its not included in behat.