Symfony 3 gives me 500 error for no errors - symfony

I have a fresh install of Symfony 3.4. Whenever i try to reach for "/" it gives me a 500 error. If i append "app_dev.php" to my route (not only "/" route, any route gives me error as of now) it works without any errors. What's the matter?
UPDATE: it seems like it's missing the debug bundle, namely the dump() function. Which is strange because i do have the dump() function, it works perfectly in my twig template. Log says:
[2018-11-23 13:04:24] request.CRITICAL: Uncaught PHP Exception
Twig_Error_Syntax: "Did you forget to run "composer require symfony/debug
bundle"? Unknown function "dump" in "index.html.twig"."
I run the required command and get this:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: don't install symfony/debug-bundle v4.1.7
... all the ay down to 3.4.1
- Installation request for symfony/debug-bundle ^4.1 -> satisfiable by symfony/debug-bundle[v4.1.0, v4.1.1, v4.1.2, v4.1.3, v4.1.4, v4.1.5, v4.1.6, v4.1.7].
- Conclusion: don't install symfony/symfony v3.4.0
Installation failed, reverting ./composer.json to its original content.
How can i solve this problem?

By default Symfony always runs in production mode. So, to prevent annoying caching and security issues when developing in your app.php in /www folder replace
$kernel = new AppKernel('prod', false);
with
$kernel = new AppKernel('dev', true);
Figured it out myself, saved me tons of time.

Related

Declaration of Symfony\Flex\ParallelDownloader::getRemoteContents(...) on Heruko

We've started today to get an error during the builds on Herko.
- Installing symfony/flex (v1.0.67): Loading from cache
Plugin installation failed, rolling back
- Removing symfony/flex (v1.0.67)
[ErrorException]
Declaration of Symfony\Flex\ParallelDownloader::getRemoteContents($originUrl, $fileUrl, $context) should be compatible with Composer\Util\RemoteFilesystem::getRemoteContents($originUrl, $fileUrl, $context, ?array &$responseHeaders = NULL)
From Googling (https://github.com/symfony/flex/issues/397) I've tried updating the flex version by just updating the composer.json to "symfony/flex": "1.0.89", then pushing the code GitHub, which then intern triggers the build on Herko, but I keep getting the same error...
After editing composer.json, you should run composer update to update your composer.lock file, then commit & push.

Sudden syntax error after deployment

I have a working symfony project. I have it on a private bitbucked repository and locally the website works without an issue.
Today I tried to deploy the project onto an external server linuxpl.com.
Steps taken include:
Istalling composer
Adding the mysql database
Running git clone to get the data into a proper location
Running composer install on the folder to install everything and connect to the db
Cleared the cache
Set the project root as ....domain/project_name/web
However after completing all these steps, when running the website with regular server:run I'm getting this odd error:
Parse error: syntax error, unexpected '.' in /home/spirifer/domains/surowcewobiektywie.pl/konkurs/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1571
Not sure if this is of any importance but the mentioned code partion looks like this in my local files:
// Some objects throw exceptions when they have __call, and the method we try
// to call is not supported. If ignoreStrictCheck is true, we should return null.
try {
$ret = $object->$method(...$arguments);
} catch (BadMethodCallException $e) {
if ($call && ($ignoreStrictCheck || !$env->isStrictVariables())) {
return;
}
throw $e;
}
The local version does not differ from the one on the server.
My local machine has PHP 7.0.9 and the remove server has PHP 7.0.14
How could I fix this issue?
PHP 5.6 adds Variadic functions, with "...". However, Twig v1.x only required the use of PHP 5.2.7 or above.
If you didn't explicitly update to Twig 2.0, it's very possible you have used the 'death star' version constraint in the composer file - '*'. which allows uncontrolled version updates to the latest version. If this is the case, you will need to either update your version of PHP, or at least require just a previous version of Twig/twig, "^1.32" would be the latest in the version 1 series of Twig.

Symfony2 SyliusShippingBundle errors when installing. Is it still working?

I need to get a few ecommerce components from bundles. So I found Sylius E-Commerce bundle. And I want to install the Shipping Bundle.
http://docs.sylius.org/en/latest/bundles/SyliusShippingBundle/index.html
However at the last part, when I need to update my schema I get this error:
Fatal error: Class 'Sylius\Component\Translation\Model\AbstractTranslatable' not found in C:\wamp\www\karpedealb2c\vendor\sylius\shipping\Model\ShippingMethod.php on line 24
So I go to the Sylius vendor and I can see that the class AbstractTranslatable doesnt exist.. I did some research and I found that these models are a part of a SyliusTranslationBundle that doesnt even exist anymore...
Do these bundles even work? Its not the first time I cant install Sylius Bundles.
P.S Are there any other good bundles that offer different e-commerce models and etc?
UPDATE
If I try to add them seperately:
"sylius/translation-bundle": "^0.15.0",
"sylius/shipping-bundle": "^0.15.0",
"sylius/resource-bundle": "0.16.*
I get these errors hen updating composer:
Problem 1
- The requested package sylius/resource-bundle could not be found in any version, there may be a typo in the package name.
Problem 2
- Installation request for sylius/translation-bundle ^0.15.0 -> satisfiable by sylius/translation-bundle[v0.15.0].
- sylius/translation-bundle v0.15.0 requires sylius/resource-bundle 0.15.*#dev -> no matching package found.
Problem 3
- Installation request for sylius/shipping-bundle ^0.15.0 -> satisfiable by sylius/shipping-bundle[v0.15.0].
- sylius/shipping-bundle v0.15.0 requires sylius/resource-bundle 0.15.*#dev -> no matching package found.

Composer.phar update now results in an ErrorException for MonologBundle

symfony/symfony v2.2.0
monolog/monolog v1.4.1
After running composer.phar update yesterday, monolog was updated; running the same command today results in the following error message:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Generating autoload files
[ErrorException]
Warning: constant(): Couldn't find constant Monolog\Logger::DEBUG in [path]\vendor\symfony\monolog-bundle\Symfony\Bundle\MonologBundle\DependencyInjection\MonologExtension.php line 109
The (i think) relevant part of config_dev.yml
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
firephp:
type: firephp
level: info
Did something change that requires additional configuration, or is something else happening ?
Monolog recently switch to PSR-4 compatible autoloading. Possibly, the
version of Composer you're running is too old for that. Please run
composer self-update first and try to update your dependencies again.
Sounds like the update didn't go well - do you have a Logger class in vendor/monolog/monolog/src/Monolog/Logger.php? If not I would suggest deleting the vendor/monolog dir and running composer install to get it back.
I had this same thing, but for Laravel.
I solved it by creating the app/storage folder and all it's sub-folders and files.
I get them by creating a new empty project, and just a copy-paste !
Woking now...
Here is the file structure:
app/storage/cache
app/storage/logs
app/storage/meta
app/storage/sessions
app/storage/views
You can ignore this folder for your repository.

How to install mmoreramerino/GearmanBundle with Symfony 2.1.x?

I am pretty new to Symfony 2 and brand new to Gearman.
I am looking for a bundle to integrate Symfony 2 with Gearman.
mmoreramerino's bundle seems to be the most popular bundle according to packagist. Unfortunately something seems to be broken, the autoloader does not find the bundle.
Fatal error: Class 'Mmoreramerino\GearmanBundle\MmoreramerinoGearmanBundle' not found in ...
I tried switching to "dev-development" as I got from the issues that it was fixed in this branch, but it did not work for me as well.
Question: How can I install this bundle using Symfony 2.1.x?
Question 2: Are there any working & documented alternatives?
Edit In case someone else comes across this question: Here is how I got it up and running!
Install gearman, libgearman, the PECL extension for PHP (use recent versions!)
check that gearman shows up in phpinfo() (both cli and webserver version)
start gearmand in terminal 1 using "gearmand --verbose INFO" (you will see workers & clients connect to gearman - or not ;-))
start in terminal 2 reverse_worker.php from the gearman php extension example directory
start in terminal 3 reverse_client.php from the gearman php extension example directory
If this is working, you are ready for Symfony: install mmoreramerino/GearmanBundle using "dev-development"
copy dev.base.yml from the bundle to app/config/gearman/dev.yml
Now add TestWorker.php to your bundle as outlined in the documentation
enable the testWorker by using the console script "php app/console gearman:job:execute MmoreramerinoGearmanBundleWorkerstestWorker~test"
now you are able to send jobs to the listening testWorker in a Symfony controller (or somewhere else in Symfony). I had to specify the server though I am using the default host/port.
$gearman = $this->get('gearman');
$gearman->setServer('127.0.0.1',4730);
$gearman->doNormalJob('MmoreramerinoGearmanBundleWorkerstestWorker~test');
To install the bundle, you need to add the following line to composer.json
"Mmoreramerino/GearmanBundle": "dev-development"
and run composer update;
Then register it in app/AppKernel.php (it seems you have already done this)
new Mmoreramerino\GearmanBundle\MmoreramerinoGearmanBundle(),

Resources