<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Symfony | Nerdpress.org</title>
	<atom:link href="https://nerdpress.org/tag/symfony-framework/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerdpress.org</link>
	<description>...dev, tech problems and solutions.</description>
	<lastBuildDate>Wed, 06 Aug 2025 07:02:57 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Symfony HTTP Client default timeout</title>
		<link>https://nerdpress.org/2025/08/06/symfony-http-client-default-timeout/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Wed, 06 Aug 2025 07:02:56 +0000</pubDate>
				<category><![CDATA[Symfony]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=3428</guid>

					<description><![CDATA[<p>Small Service Post: The default timeout of the Symfony HTTP Client is 60s (seconds)! Sure, it is mentioned in the Symfony HTTP Client docs, that PHP&#8217;s default_socket_timeout is taken as default value.So what is the default_socket_timeout then, you might wonder? One click away in PHP Runtime Configuration docs you will find that in the php.ini &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2025/08/06/symfony-http-client-default-timeout/" class="more-link">Continue reading<span class="screen-reader-text"> "Symfony HTTP Client default timeout"</span></a></p>
The post <a href="https://nerdpress.org/2025/08/06/symfony-http-client-default-timeout/">Symfony HTTP Client default timeout</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p><br />Small Service Post:<br /><br />The default timeout of the Symfony HTTP Client is <strong>60s</strong> (seconds)!<br /><br />Sure, it is mentioned in the <a href="https://symfony.com/doc/current/reference/configuration/framework.html#timeout" title="">Symfony HTTP Client docs</a>, that PHP&#8217;s <em>default_socket_timeout</em> is taken as default value.<br />So what is the default_socket_timeout then, you might wonder?</p>



<p>One click away in <a href="https://www.php.net/manual/en/filesystem.configuration.php" target="_blank" rel="noopener" title="">PHP Runtime Configuration docs</a> you will find that in the php.ini the default value is &#8220;60&#8221;. <br />In case you wonder what unit these &#8220;60&#8221; is, you will find <em>(in seconds)</em> a bit down below the config table. <br />&#8211; Yeah, seconds was my first guess, but I need to assure it is not microseconds by any chance. &#8211;</p>



<p>And thats it! Thats the post.</p>



<p>P.S: It is funny how scattered information sometimes is, although is all there. <br />AI did know, but did not name a source. <br />And since AI is not to trust, I still had to look it up via Search.</p>The post <a href="https://nerdpress.org/2025/08/06/symfony-http-client-default-timeout/">Symfony HTTP Client default timeout</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Symfony integration tests custom header is missing</title>
		<link>https://nerdpress.org/2024/06/14/symfony-integration-tests-custom-header-is-missing/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Fri, 14 Jun 2024 14:27:00 +0000</pubDate>
				<category><![CDATA[Symfony]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=3316</guid>

					<description><![CDATA[<p>I am writing an integration test in Symfony with a request that includes custom headers. However, the request fails because the custom header is apparently missing. What happened was I forgot to add an HTTP prefix to the custom header. This is a common pitfall when writing integration tests in Symfony and using custom HTTP &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2024/06/14/symfony-integration-tests-custom-header-is-missing/" class="more-link">Continue reading<span class="screen-reader-text"> "Symfony integration tests custom header is missing"</span></a></p>
The post <a href="https://nerdpress.org/2024/06/14/symfony-integration-tests-custom-header-is-missing/">Symfony integration tests custom header is missing</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>I am writing an integration test in Symfony with a request that includes custom headers. However, the request fails because the custom header is apparently missing. <br />What happened was I forgot to add an HTTP prefix to the custom header.</p>



<p>This is a common pitfall when writing integration tests in Symfony and using custom HTTP headers: the necessity to add an <strong>HTTP_</strong> prefix to the header in the test. <br />If you do not add the prefix to the custom header, it will silently not be added to the request, and you have to debug why the request fails.</p>



<p>So this will fail:</p>


<pre class="wp-block-code"><span><code class="hljs language-php"><span class="hljs-keyword">static</span>::$client-&gt;request(<span class="hljs-string">'GET'</span>, <span class="hljs-string">'/ping'</span>, &#91;], &#91;], &#91;<span class="hljs-string">'X-Custom-Header'</span> =&gt; <span class="hljs-string">'custom'</span>]);</code></span></pre>


<p>And this will work:</p>


<pre class="wp-block-code"><span><code class="hljs language-php"><span class="hljs-keyword">static</span>::$client-&gt;request(<span class="hljs-string">'GET'</span>, <span class="hljs-string">'/ping'</span>, &#91;], &#91;], &#91;<span class="hljs-string">'HTTP_X-Custom-Header'</span> =&gt; <span class="hljs-string">'custom'</span>]);</code></span></pre>


<span id="more-3316"></span>



<p>According to the <a href="https://symfony.com/doc/current/testing.html#sending-custom-headers" target="_blank" rel="noopener" title="">documentation</a>, you would actually also need to transform it to uppercase and replace the dash with an underscore but it will work with just the HTTP prefix.</p>



<p>HTTP_X_CUSTOM_HEADER</p>



<p>The prefix is however not necessary for not custom but standard headers like &#8216;Content-Type&#8217;.</p>



<p>This is not an intuitive requirement, and I wish it were not necessary. <br />At the very least, a warning would be nice when the test client encounters a non-prefixed, non-standard header.</p>



<p>A related StackOverflow Post: <a href="https://stackoverflow.com/questions/11549672/symfony-functional-test-custom-headers-not-passing-through" target="_blank" rel="noopener" title="">https://stackoverflow.com/questions/11549672/symfony-functional-test-custom-headers-not-passing-through</a></p>The post <a href="https://nerdpress.org/2024/06/14/symfony-integration-tests-custom-header-is-missing/">Symfony integration tests custom header is missing</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Stream an image from Symfony controller</title>
		<link>https://nerdpress.org/2022/12/12/stream-an-image-from-symfony-controller/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Mon, 12 Dec 2022 09:26:26 +0000</pubDate>
				<category><![CDATA[Symfony]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=3190</guid>

					<description><![CDATA[<p>When sending an image/file from a Symfony controller you would usually read the file from filesystem.This you can do by passing the file path to the BinaryFileResponse class and return it in the controller, as described in the docs:https://symfony.com/doc/current/components/http_foundation.html#serving-files But in some cases you might want to create an image dynamically and return it directly &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2022/12/12/stream-an-image-from-symfony-controller/" class="more-link">Continue reading<span class="screen-reader-text"> "Stream an image from Symfony controller"</span></a></p>
The post <a href="https://nerdpress.org/2022/12/12/stream-an-image-from-symfony-controller/">Stream an image from Symfony controller</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>When sending an image/file from a Symfony controller you would usually read the file from filesystem.<br />This you can do by passing the file path to the BinaryFileResponse class and return it in the controller, as described in the docs:<br /><a href="https://symfony.com/doc/current/components/http_foundation.html#serving-files" target="_blank" rel="noreferrer noopener">https://symfony.com/doc/current/components/http_foundation.html#serving-files</a></p>


<pre class="wp-block-code"><span><code class="hljs language-php"><span class="hljs-keyword">use</span> <span class="hljs-title">Symfony</span>\<span class="hljs-title">Component</span>\<span class="hljs-title">HttpFoundation</span>\<span class="hljs-title">BinaryFileResponse</span>;

$file = <span class="hljs-string">'path/to/file.txt'</span>;
$response = <span class="hljs-keyword">new</span> BinaryFileResponse($file);</code></span></pre>


<p>But in some cases you might want to create an image dynamically and return it directly from the controller without storing it on the filesystem.<br />So you can create your image with the GD library and directly stream the GDImage object from the symfony controller with the <em>StreamedResponse</em> class.</p>



<span id="more-3190"></span>


<pre class="wp-block-code"><span><code class="hljs language-php">$image = imagecreatetruecolor($imgWidth, $imgHeight);
<span class="hljs-comment">// do something with the image</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> StreamedResponse(fn () =&gt; imagepng($image), <span class="hljs-number">200</span>, &#91;<span class="hljs-string">'Content-Type'</span> =&gt; <span class="hljs-string">'image/png'</span>]);</code></span></pre>


<p>Great that was easy, but not so obvious ;)</p>



<p>Another thing you might wonder is how to add the OpenAPI annotation when streaming images to generate a proper documentation for your endpoints.<br />Just use <em>MediaType </em>class in the Response annotation and set the format to binary.</p>


<pre class="wp-block-code"><span><code class="hljs language-php">responses: &#91;
	<span class="hljs-keyword">new</span> OA\Response(
		response: <span class="hljs-number">200</span>,
		description: <span class="hljs-string">"dynamic image"</span>,
		content: <span class="hljs-keyword">new</span> OA\MediaType(
			mediaType: <span class="hljs-string">'image/png'</span>, 
			schema: <span class="hljs-keyword">new</span> OA\Schema(
				type: <span class="hljs-string">'string'</span>,
				format: <span class="hljs-string">'binary'</span>
			)
		)
	),
]</code></span></pre>


<p>Then finally you should test the <em>StreamedResponse</em> from the controller.<br />For this you can not use the normal <code>$client-&gt;getResponse()</code> but instead use the <em>getInternalResponse</em> which holds the binary data as string however.<br />So to test the binary response in your test add this:</p>


<pre class="wp-block-code"><span><code class="hljs language-php">$response = <span class="hljs-keyword">static</span>::$client-&gt;getInternalResponse();
$image = $response-&gt;getContent();
		
<span class="hljs-keyword">self</span>::assertInstanceOf(GdImage::class, imagecreatefromstring($image));</code></span></pre>


<p>This seems to be valid from Symfony 4 upwards.<br />Before Symfony 4 you could get the binary data from <code>$client-&gt;getResponse()</code>.</p>The post <a href="https://nerdpress.org/2022/12/12/stream-an-image-from-symfony-controller/">Stream an image from Symfony controller</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Symfony deprecation log channel</title>
		<link>https://nerdpress.org/2022/09/13/symfony-deprecation-log-channel/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Tue, 13 Sep 2022 13:53:02 +0000</pubDate>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Logging]]></category>
		<category><![CDATA[Monolog]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=3170</guid>

					<description><![CDATA[<p>Are you annoyed of too many deprecation warnings in you logs of your symfony app?Probably yes because it is really a lot of noise.However deprecation logs are still useful to ensure future compatibility of your app. So since version 5.1 symfony will log deprecations to a dedicated log channel when it exists and ships with &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2022/09/13/symfony-deprecation-log-channel/" class="more-link">Continue reading<span class="screen-reader-text"> "Symfony deprecation log channel"</span></a></p>
The post <a href="https://nerdpress.org/2022/09/13/symfony-deprecation-log-channel/">Symfony deprecation log channel</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>Are you annoyed of too many deprecation warnings in you logs of your symfony app?<br />Probably yes because it is really a lot of noise.<br />However deprecation logs are still useful to ensure future compatibility of your app.</p>



<p>So since version 5.1 symfony will log deprecations to a dedicated log channel when it exists and ships with this monolog config:</p>


<pre class="wp-block-code"><span><code class="hljs language-php">monolog:
    channels:
        - deprecation <span class="hljs-comment"># Deprecations are logged in the dedicated "deprecation" channel when it exists</span></code></span></pre>


<p>This is added already in the <a href="https://github.com/symfony/recipes/blob/main/symfony/monolog-bundle/3.1/config/packages/prod/deprecations.yaml" target="_blank" rel="noreferrer noopener">recipe</a> and ships when installing symfony.</p>



<p>Ok, but the handler for this deprecation channel is not configured, so you have to do this yourself.<br />How? Add this to your monolog config:</p>



<span id="more-3170"></span>


<pre class="wp-block-code"><span><code class="hljs language-javascript">...
when@dev:
   monolog:
       handlers:
           main:
	       type: stream
	       <span class="hljs-attr">path</span>: <span class="hljs-string">"%kernel.logs_dir%/%kernel.environment%.log"</span>
	       <span class="hljs-attr">level</span>: debug
	       <span class="hljs-attr">channels</span>: &#91;<span class="hljs-string">"!event"</span>, <span class="hljs-string">"!deprecation"</span>]
	   <span class="hljs-attr">deprecation</span>:
	       type: rotating_file
	       <span class="hljs-attr">path</span>: <span class="hljs-string">"%kernel.logs_dir%/%kernel.environment%.deprecations.log"</span>
	       <span class="hljs-attr">max_files</span>: <span class="hljs-number">2</span>
	       <span class="hljs-attr">channels</span>: &#91;deprecation]
	   <span class="hljs-attr">console</span>:
	       type: <span class="hljs-built_in">console</span>
	       <span class="hljs-attr">process_psr_3_messages</span>: <span class="hljs-literal">false</span>
               <span class="hljs-attr">channels</span>: &#91;<span class="hljs-string">"!event"</span>, <span class="hljs-string">"!doctrine"</span>, <span class="hljs-string">"!console"</span>, <span class="hljs-string">"!deprecation"</span>]
...
</code></span></pre>


<p>What is happening here?<br />We declare a new handler for deprecations named <code>deprecation</code> when in dev environment.<br />This handler listens to the deprecation channel.<br />We declare it as a rotating file since the assumption is we dont need to keep this log entries for longer.<br />The other handlers will ignore the deprecation channel by adding a !deprecation to the channel directive.</p>



<p>The deprecation channel was already created and so all deprecations are now not in the main log file but in a dedicated deprecation log file.</p>



<p>For production we dont need to edit configuration since the log level here is info and therefore deprecations will not be considered anyway.</p>The post <a href="https://nerdpress.org/2022/09/13/symfony-deprecation-log-channel/">Symfony deprecation log channel</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Converting umlaute with symfony String component</title>
		<link>https://nerdpress.org/2022/07/18/converting-umlaute-with-symfony-string-component/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 18 Jul 2022 10:03:11 +0000</pubDate>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[umlaut]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=3159</guid>

					<description><![CDATA[<p>There are multiple PHP native ways to convert umlaute and other special characters to ascii save formats, but most of them i experience insufficient in the one or other way. Since i am using symfony anyway i can use the String component which has a handy slugger which converts any characters into safe ascii characters.It &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2022/07/18/converting-umlaute-with-symfony-string-component/" class="more-link">Continue reading<span class="screen-reader-text"> "Converting umlaute with symfony String component"</span></a></p>
The post <a href="https://nerdpress.org/2022/07/18/converting-umlaute-with-symfony-string-component/">Converting umlaute with symfony String component</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>There are multiple PHP native ways to convert umlaute and other special characters to ascii save formats, but most of them i experience insufficient in the one or other way.</p>



<p>Since i am using symfony anyway i can use the <a href="https://symfony.com/doc/current/components/string.html" target="_blank" rel="noreferrer noopener" title="https://symfony.com/doc/current/components/string.html">String component</a> which has a handy slugger which converts any characters into safe ascii characters.<br />It is very flexible and can be customized with locales, custom replacements and closures.</p>


<pre class="wp-block-code"><span><code class="hljs language-php">$umlautString = <span class="hljs-string">"Müller Meier"</span>;
$slugger = <span class="hljs-keyword">new</span> Symfony\Component\String\Slugger\AsciiSlugger(<span class="hljs-string">'de'</span>);
$slugger-&gt;slug($umlautString, $seperator = <span class="hljs-string">' '</span>)-&gt;toString();
<span class="hljs-keyword">echo</span> $umlautString; <span class="hljs-comment">// mueller meier</span></code></span></pre>


<p>I guess this will become my go-to method resp. slugger to convert umlaute in any PHP application.</p>



<span id="more-3159"></span>



<p>One example why the PHP native ways have their downsides is iconv.<br />Iconv can transliterate umlauts:</p>


<pre class="wp-block-code"><span><code class="hljs language-php">$string = iconv(<span class="hljs-string">'UTF-8'</span>, <span class="hljs-string">'ASCII//TRANSLIT'</span>, $string);</code></span></pre>


<p>But it can not handle the locale in a convenient way but relies on the system wide locale instead.<br />You need to use the global method <code>setlocale</code> before using it and reset the locale after usage again, which can cause sideeffects and is not very convenient.</p>



<p>From: <a href="https://www.php.net/manual/de/function.iconv.php#105507">https://www.php.net/manual/de/function.iconv.php#105507</a></p>


<pre class="wp-block-code"><span><code class="hljs language-php">$utf8_sentence = <span class="hljs-string">'Weiß, Göbel'</span>;
<span class="hljs-comment">//transliterate</span>
$trans_sentence = iconv(<span class="hljs-string">'UTF-8'</span>, <span class="hljs-string">'ASCII//TRANSLIT'</span>, $utf8_sentence);
<span class="hljs-comment">//gives &#91;Weiss, Gobel]</span>
<span class="hljs-comment">//Germany</span>
setlocale(LC_ALL, <span class="hljs-string">'de_DE'</span>);
$trans_sentence = iconv(<span class="hljs-string">'UTF-8'</span>, <span class="hljs-string">'ASCII//TRANSLIT'</span>, $utf8_sentence);
<span class="hljs-comment">//gives &#91;Weiss, Goebel]</span></code></span></pre>


<p>Thanks to this StackOverflow answer for the tip with the symfony String component. <a href="https://stackoverflow.com/a/68742023/541949" target="_blank" rel="noreferrer noopener">https://stackoverflow.com/a/68742023/541949</a></p>The post <a href="https://nerdpress.org/2022/07/18/converting-umlaute-with-symfony-string-component/">Converting umlaute with symfony String component</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Migrating user table from Mysql to Postgres with Symfony and Doctrine</title>
		<link>https://nerdpress.org/2021/11/10/migrating-user-table-from-mysql-to-postgres-with-symfony-and-doctrine/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Wed, 10 Nov 2021 08:46:07 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[Postgres]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=3087</guid>

					<description><![CDATA[<p>When using bin/console make:entity on Mysql and then later you switch your application to Postgres and you have a table called user, which you most likely have when using security component of Symfony.Then you will receive an error because user is a reserved word in Postgres! An exception occurred while executing 'INSERT INTO user (id, &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2021/11/10/migrating-user-table-from-mysql-to-postgres-with-symfony-and-doctrine/" class="more-link">Continue reading<span class="screen-reader-text"> "Migrating user table from Mysql to Postgres with Symfony and Doctrine"</span></a></p>
The post <a href="https://nerdpress.org/2021/11/10/migrating-user-table-from-mysql-to-postgres-with-symfony-and-doctrine/">Migrating user table from Mysql to Postgres with Symfony and Doctrine</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>When using <code>bin/console make:entity</code> on Mysql and then later you switch your application to Postgres and you have a table called <code>user</code>, which you most likely have when using security component of Symfony.<br />Then you will receive an error because <code>user</code> is a reserved word in Postgres!</p>



<p><code>An exception occurred while executing 'INSERT INTO user (id, email, roles, password, is_verified) VALUES (?, ?, ?, ?, ?)' with params [3, "dev@dev.de", "[]", "your-encrypted-password", 0]:<br />SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "user"<br />LINE 1: INSERT INTO user (id, email, roles, password, is_verified) V...</code></p>



<span id="more-3087"></span>



<p>To fix this you have to escape the table name on your entity, fe. User.php:<br /><br />@<code>ORM\Table(name="`user`")</code></p>



<p>(<strong>note the backticks inside the quotes!)</strong></p>



<p>If you generate the entity with <a href="https://symfony.com/bundles/SymfonyMakerBundle/current/index.html" target="_blank" rel="noreferrer noopener">maker bundle</a>: <code>bin/console make:entity</code> directly on Postgres the backticks are added automatically.<br />But not when you switch the DB type. Then you have to add them manually. :)</p>



<p><br /></p>The post <a href="https://nerdpress.org/2021/11/10/migrating-user-table-from-mysql-to-postgres-with-symfony-and-doctrine/">Migrating user table from Mysql to Postgres with Symfony and Doctrine</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Passing a boolean to the constructor of &#8220;Symfony\Component\Dotenv\Dotenv&#8221; is deprecated</title>
		<link>https://nerdpress.org/2021/04/12/passing-a-boolean-to-the-constructor-of-symfonycomponentdotenvdotenv-is-deprecated/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Mon, 12 Apr 2021 10:06:21 +0000</pubDate>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=3034</guid>

					<description><![CDATA[<p>You might encounter this deprecation message after your upgrade to symfony 5.1 in your symfony project: Since symfony/dotenv 5.1: Passing a boolean to the constructor of &#8220;Symfony\Component\Dotenv\Dotenv&#8221; is deprecated, use &#8220;Dotenv::usePutenv() To fix this, go to config/bootstrap.php and remove the false from the Dotenv constructor:(new Dotenv(false))-&#62;loadEnv(dirname(DIR).'/.env');to(new Dotenv())-&#62;loadEnv(dirname(DIR).'/.env');See: https://github.com/symfony/symfony/issues/37195 Actually the file config/bootstrap.php has been removed &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2021/04/12/passing-a-boolean-to-the-constructor-of-symfonycomponentdotenvdotenv-is-deprecated/" class="more-link">Continue reading<span class="screen-reader-text"> "Passing a boolean to the constructor of &#8220;Symfony\Component\Dotenv\Dotenv&#8221; is deprecated"</span></a></p>
The post <a href="https://nerdpress.org/2021/04/12/passing-a-boolean-to-the-constructor-of-symfonycomponentdotenvdotenv-is-deprecated/">Passing a boolean to the constructor of “Symfony\Component\Dotenv\Dotenv” is deprecated</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>You might encounter this deprecation message after your upgrade to symfony 5.1 in your symfony project:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Since symfony/dotenv 5.1: Passing a boolean to the constructor of &#8220;Symfony\Component\Dotenv\Dotenv&#8221; is deprecated, use &#8220;Dotenv::usePutenv()</p></blockquote>



<p>To fix this, go to <em>config/bootstrap.php</em> and remove the <code>false</code> from the Dotenv constructor:<br /><code>(new Dotenv(false))-&gt;loadEnv(dirname(<strong>DIR</strong>).'/.env');</code><br />to<br /><code>(new Dotenv())-&gt;loadEnv(dirname(<strong>DIR</strong>).'/.env');</code><br />See: https://github.com/symfony/symfony/issues/37195</p>



<p>Actually the file <em>config/bootstrap.php</em> has been removed from symfony 5.1 and was replaced in <a href="https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/5.1/public/index.php" target="_blank" rel="noreferrer noopener" title="https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/5.1/public/index.php">public/index.php</a>.</p>



<p>But since the project was updated from an symfony 4 version the bootrap file is still present.</p>



<p>So another option would be to remove the boostrap file and update the project entirely to <a href="https://github.com/symfony/recipes/tree/master/symfony/framework-bundle/5.1" target="_blank" rel="noreferrer noopener">symfony 5.1 recipe</a>.<br />This is not trivial though as you can see in this corresponfing <a href="https://github.com/symfony/recipes/pull/724" target="_blank" rel="noreferrer noopener">PullRequest</a>.</p>The post <a href="https://nerdpress.org/2021/04/12/passing-a-boolean-to-the-constructor-of-symfonycomponentdotenvdotenv-is-deprecated/">Passing a boolean to the constructor of “Symfony\Component\Dotenv\Dotenv” is deprecated</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Disable symfony deprecation warnings in PHPUnit tests</title>
		<link>https://nerdpress.org/2019/08/29/disable-symfony-deprecation-warnings-in-phpunit-tests/</link>
					<comments>https://nerdpress.org/2019/08/29/disable-symfony-deprecation-warnings-in-phpunit-tests/#comments</comments>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Thu, 29 Aug 2019 07:39:23 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[PHPUnit]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2878</guid>

					<description><![CDATA[<p>Symfony&#8217;s deprecation warnings while running tests is a great service to keep track with upcoming changes in newer symfony versions. However these warnings can break your CI/CD pipeline and sometimes you cant fix all deprecation warnings immediatly. To disable them you can set the ENV var SYMFONY_DEPRECATIONS_HELPER=disabled and the warnings will not be displayed anymore &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2019/08/29/disable-symfony-deprecation-warnings-in-phpunit-tests/" class="more-link">Continue reading<span class="screen-reader-text"> "Disable symfony deprecation warnings in PHPUnit tests"</span></a></p>
The post <a href="https://nerdpress.org/2019/08/29/disable-symfony-deprecation-warnings-in-phpunit-tests/">Disable symfony deprecation warnings in PHPUnit tests</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>Symfony&#8217;s deprecation warnings while running tests is a great service to keep track with upcoming changes in newer symfony versions.<br> However these warnings can break your CI/CD pipeline and sometimes you cant fix all deprecation warnings immediatly.</p>



<p>To disable them you can set the ENV var <br><code>SYMFONY_DEPRECATIONS_HELPER=disabled</code> <br>and the warnings will not be displayed anymore and CI/CD will pass again.<strong><br>Update from comments:</strong><code><br>SYMFONY_DEPRECATIONS_HELPER=weak</code> does also work and will still show the deprecation warnings count. (Thx Max)</p>



<span id="more-2878"></span>



<p> This was introduced a while ago with this <a rel="noreferrer noopener" aria-label="PullRequest (opens in a new tab)" href="https://github.com/symfony/symfony/pull/18232" target="_blank">PullRequest</a> and works for symfony >= 3.1.</p>



<p>So for running the tests manually, do like this:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
SYMFONY_DEPRECATIONS_HELPER=disabled vendor/bin/phpunit
</pre></div>


<p>Or add it to the phpunit.xml</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&amp;lt;php&gt;
    &amp;lt;ini name=&quot;error_reporting&quot; value=&quot;-1&quot; /&gt;
    &amp;lt;env name=&quot;KERNEL_CLASS&quot; value=&quot;App\Kernel&quot; /&gt;
    ...
    &amp;lt;env name=&quot;SYMFONY_DEPRECATIONS_HELPER&quot; value=&quot;disabled&quot; /&gt;
&amp;lt;/php&gt;
</pre></div>


<p>With bitbucket pipelines it looks like this:</p>



<pre class="wp-block-preformatted"><code>pipelines:<br>   branches:<br>     master:<br>       - step:<br>           script:<br>             - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer<br>             - composer install<br>             - SYMFONY_DEPRECATIONS_HELPER=disabled composer test<br>             - composer check-style</code></pre>The post <a href="https://nerdpress.org/2019/08/29/disable-symfony-deprecation-warnings-in-phpunit-tests/">Disable symfony deprecation warnings in PHPUnit tests</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
					<wfw:commentRss>https://nerdpress.org/2019/08/29/disable-symfony-deprecation-warnings-in-phpunit-tests/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Symfony Workflow Component: Dump workflows as PDF</title>
		<link>https://nerdpress.org/2017/11/07/symfony-workflow-component-dump-workflows-pdf/</link>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Tue, 07 Nov 2017 05:10:59 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[graphviz]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[workflow]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2787</guid>

					<description><![CDATA[<p>One very cool feature of the Symfony Workflow Component is the ability to export workflows via graphviz. Did you know you can also directly render those as PDF files? It&#8217;s actually quite easy. Like so:</p>
The post <a href="https://nerdpress.org/2017/11/07/symfony-workflow-component-dump-workflows-pdf/">Symfony Workflow Component: Dump workflows as PDF</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>One very cool feature of the Symfony Workflow Component is the ability to export workflows via graphviz.</p>
<p>Did you know you can also directly render those as PDF files?<br />
<span id="more-2787"></span></p>
<p>It&#8217;s actually quite easy. Like so:</p>
<pre class="brush: bash; title: ; notranslate">
php bin/console workflow:dump myWorkflow | dot -Tpdf &gt; data/workflow/myWorkflow.pdf
</pre>The post <a href="https://nerdpress.org/2017/11/07/symfony-workflow-component-dump-workflows-pdf/">Symfony Workflow Component: Dump workflows as PDF</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Symfony and Angular: shared translations</title>
		<link>https://nerdpress.org/2017/09/04/symfony-and-angular-shared-translations/</link>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Mon, 04 Sep 2017 15:21:51 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Project Setup]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Angular.js]]></category>
		<category><![CDATA[i18n]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2742</guid>

					<description><![CDATA[<p>Angular for frontend with symfony delivering the data have become quite a common setup. When working with this constellation you will sooner or later come across the i18n topic. Most likely you would want to share translations between front- and backend. So that you could keep translations in one single location while using it for &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2017/09/04/symfony-and-angular-shared-translations/" class="more-link">Continue reading<span class="screen-reader-text"> "Symfony and Angular: shared translations"</span></a></p>
The post <a href="https://nerdpress.org/2017/09/04/symfony-and-angular-shared-translations/">Symfony and Angular: shared translations</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p><a href="https://angularjs.org/">Angular</a> for frontend with <a href="http://symfony.com/">symfony</a> delivering the data have become quite a common setup.</p>
<p>When working with this constellation you will sooner or later come across the i18n topic. Most likely you would want to share translations between front- and backend. So that you could keep translations in one single location while using it for frontend templates as well as server-side error messages etc.</p>
<p>One <a href="https://stackoverflow.com/questions/19686291/translations-shared-between-symfony2-and-angular-js">approach</a> would be to store translations in the symfony yml or xml files and deliver those to the frontend via an api endpoint.<br />
Given that front- and backend-code run <strong>on the same server</strong>, there is an even simpler solution.<br />
<span id="more-2742"></span></p>
<p>Since symfony does not only read <a href="https://symfony.com/doc/current/components/translation.html#loading-message-catalogs">yml or xml</a> but also translations in the <a href="https://symfony.com/doc/current/components/translation.html#loading-message-catalogs">json format</a>, you can simply keep translations in the frontend and read those files with symfony directly.</p>
<p>All you need to do to achieve this is <a href="https://en.wikipedia.org/wiki/Symbolic_link">symlink</a> the angular translation files to your symfony translation catalog location. </p>
<pre class="brush: bash; title: ; notranslate">
messages.de.json -&gt; ../../../web/ng/I18n/de_DE.json
messages.en.json -&gt; ../../../web/ng/I18n/en_EN.json
</pre>
<p><em>Disclaimer: This works only for relatively simple use cases with no complex translation patterns. But hey&#8230;</em></p>The post <a href="https://nerdpress.org/2017/09/04/symfony-and-angular-shared-translations/">Symfony and Angular: shared translations</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
