<?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>Project Setup | Nerdpress.org</title>
	<atom:link href="https://nerdpress.org/category/project-setup/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerdpress.org</link>
	<description>...dev, tech problems and solutions.</description>
	<lastBuildDate>Fri, 08 Nov 2024 12:38:47 +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>Deploy local build with Deployer7</title>
		<link>https://nerdpress.org/2024/11/08/deploy-local-build-with-deployer7/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Fri, 08 Nov 2024 12:38:46 +0000</pubDate>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Deployer]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=3347</guid>

					<description><![CDATA[<p>Deployer is a great tool to deploy your PHP Project. Deployer executes a set of commands on the target server to build your project and enable the newly built version. A typical deployment process with Deployer involves SSHing into the target machine, where it performs a Git checkout of the project, installs dependencies via Composer, &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2024/11/08/deploy-local-build-with-deployer7/" class="more-link">Continue reading<span class="screen-reader-text"> "Deploy local build with Deployer7"</span></a></p>
The post <a href="https://nerdpress.org/2024/11/08/deploy-local-build-with-deployer7/">Deploy local build with Deployer7</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p><br /><a href="https://deployer.org/" target="_blank" rel="noopener" title="">Deployer</a> is a great tool to deploy your PHP Project.</p>



<p>Deployer executes a set of commands on the target server to build your project and enable the newly built version. A typical deployment process with Deployer involves SSHing into the target machine, where it performs a Git checkout of the project, installs dependencies via Composer, runs build commands, and possibly triggers some database migrations. When everything is successful, it will symlink the webroot to the new release.</p>



<p>On some servers, however, there are limitations that make this process unfeasible. For instance, you can&#8217;t install Composer, Git isn&#8217;t available, the CLI PHP version is different and can&#8217;t be changed, or certain asset-building processes aren&#8217;t possible because Node.js isn&#8217;t installed. This is often the case with shared hosting.</p>



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



<p>The strategy, therefore, is to build the project locally and upload it to the target machine. <br />In Deployer 6 there was a buildIn mechanism for building your project on the local host.<br />However with Deployer version 7 this has been removed and building your project locally has become a bit more fiddly. <br /><br />With Deployer 6 you could just use the <code>local</code>() method on a task and set the <code>deploy_path</code> to a local dir.</p>


<pre class="wp-block-code"><span><code class="hljs language-php">task(<span class="hljs-string">'build'</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">()</span> </span>{
    set(<span class="hljs-string">'deploy_path'</span>, <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/.build'</span>);
    invoke(<span class="hljs-string">'deploy:prepare'</span>);
    invoke(<span class="hljs-string">'deploy:release'</span>);
    invoke(<span class="hljs-string">'deploy:update_code'</span>);
    invoke(<span class="hljs-string">'deploy:vendors'</span>);
    invoke(<span class="hljs-string">'deploy:clear_paths'</span>);
    invoke(<span class="hljs-string">'deploy:symlink'</span>);
})-&gt;local();</code></span></pre>


<p>Then you could combine this with an upload task in a deploy task an you are done.</p>


<pre class="wp-block-code"><span><code class="hljs language-php">task(<span class="hljs-string">'upload'</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">()</span> </span>{
     upload(<span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">"/.build/current/"</span>, <span class="hljs-string">'{{release_path}}'</span>, &#91;<span class="hljs-string">'--links'</span>]);
 });

 task(<span class="hljs-string">'deploy'</span>, &#91;
     <span class="hljs-string">'build'</span>,
     <span class="hljs-string">'upload'</span>,
     <span class="hljs-string">'cleanup'</span>,
     <span class="hljs-string">'success'</span>
 ]);</code></span></pre>


<p>See here for the docs of Deployer 6: <br /><a href="https://deployer.org/docs/6.x/advanced/deploy-strategies#build-server" target="_blank" rel="noopener" title="">https://deployer.org/docs/6.x/advanced/deploy-strategies#build-server</a></p>



<p>Since Deployer 7, however, the <code>local()</code> method was removed. Instead, there is now a <code>localhost()</code> method, which defines a host for local builds. Additionally, you still need to define the remote host as the target destination for the upload. <br />However, you cannot specify a single task to run on a specific host, and therefore you cannot combine tasks for <code>localhost</code> and the remote host within a single task.</p>



<p>To build the project, we now need two separate tasks. <br />I managed to make it work with two tasks and two hosts: one for local build and one that takes the fresh local build and uploads it to the remote host.</p>


<pre class="wp-block-code"><span><code class="hljs language-php">localhost(<span class="hljs-string">'local'</span>)-&gt;set(<span class="hljs-string">'deploy_path'</span>, <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/.build'</span>);

host(<span class="hljs-string">'remote'</span>)
    -&gt;setHostname(<span class="hljs-string">'server-host.com'</span>)
    -&gt;set(<span class="hljs-string">'remote_user'</span>, <span class="hljs-string">'user'</span>)
    -&gt;set(<span class="hljs-string">'deploy_path'</span>, <span class="hljs-string">'/www/blog'</span>)
    -&gt;set(<span class="hljs-string">'http_user'</span>, <span class="hljs-string">'user'</span>);
....

task(<span class="hljs-string">'build'</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">()</span> </span>{
    <span class="hljs-comment">// build it</span>
})-&gt;once();

task(<span class="hljs-string">'upload'</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">()</span> </span>{
    upload(<span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">"/.build/current/"</span>, <span class="hljs-string">'{{deploy_path}}'</span>, &#91;<span class="hljs-string">'--links'</span>]);
});</code></span></pre>


<p>Then I simply run two separate commands: one for building on the local host and one for uploading to the remote host.</p>


<pre class="wp-block-code"><span><code class="hljs">vendor/bin/dep build local
vendor/bin/dep upload remote</code></span></pre>


<p>Not as convenient as previously but it works. :)</p>



<p>See this issue for context:  <a href="https://github.com/deployphp/deployer/issues/2838" target="_blank" rel="noopener" title="">https://github.com/deployphp/deployer/issues/2838</a></p>The post <a href="https://nerdpress.org/2024/11/08/deploy-local-build-with-deployer7/">Deploy local build with Deployer7</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Import data into MySql with docker-compose</title>
		<link>https://nerdpress.org/2023/02/24/import-data-into-mysql-with-docker-compose/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Fri, 24 Feb 2023 10:04:31 +0000</pubDate>
				<category><![CDATA[docker-compose]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[PHPStorm]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=3221</guid>

					<description><![CDATA[<p>Having a docker-compose setup which involves a Database like Mysql or MariaDB, then at some point you might want to import data into those Databases. There are several ways to import the data in your docker-compose setup. So let&#8217;s see how we can do this: 1. Using a volume for import data This applies to &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2023/02/24/import-data-into-mysql-with-docker-compose/" class="more-link">Continue reading<span class="screen-reader-text"> "Import data into MySql with docker-compose"</span></a></p>
The post <a href="https://nerdpress.org/2023/02/24/import-data-into-mysql-with-docker-compose/">Import data into MySql with docker-compose</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>Having a docker-compose setup which involves a Database like Mysql or MariaDB, then at some point you might want to import data into those Databases.</p>



<p>There are several ways to import the data in your docker-compose setup.</p>



<ol class="wp-block-list">
<li>Using a volume for import data</li>



<li>Using mysql client from commandline with docker-compose exec</li>



<li>Using phpmyadmin in docker-compose setup</li>



<li>Using a mysql GUI client on the host and connect to the DB in the Docker container</li>
</ol>



<p>So let&#8217;s see how we can do this:</p>



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



<h2 class="wp-block-heading">1. Using a volume for import data</h2>



<p>This applies to both official <a href="https://hub.docker.com/_/mysql/" target="_blank" rel="noopener" title="">Mysql</a><em> and <a href="https://hub.docker.com/_/mariadb/" target="_blank" rel="noopener" title="">MariaDB</a></em> official images.<br />These have builtin import mechanism to import data.<br />To quote from the docs:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>Furthermore, it will execute files with extensions .sh, .sql and .sql.gz that are found in /docker-entrypoint-initdb.d. Files will be executed in alphabetical order. You can easily populate your mysql services by mounting a SQL dump into that directory</p>
</blockquote>



<p>So all dumps that are found in the <em>/docker-entrypoint-initdb.d</em> directory of the image will be imported unless the database already contains data.</p>



<p>So let&#8217;s add this volume to our docker-compose.yaml</p>



<p><code>volumes: - ./database_dump.sql:/docker-entrypoint-initdb.d/datadump.sql</code></p>



<p>On next <code>docker-compose up</code> the data will be imported in your empty database.<br />You will see something like this in your docker-compose logs:</p>



<p>2023-02-06 15:40:16+00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/database_dump.sql</p>



<p>Note: if there is already data in the database you need to clear the data first by f.e. clearing the volume, otherwise the import will not start:<br />You can clear all volumes of your docker-compose setup with (caution: this will clear <em>all</em> volumes, not just the database volume):</p>



<p><code>docker-compose down -v</code></p>



<h2 class="wp-block-heading">2. Using mysql client from commandline with docker-compose exec</h2>



<p>With this one liner you can import a SQL dump from a docker image that has a MySql/MariaDB client installed and are linked to the DB container:</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript">docker-compose exec my-app bash -c <span class="hljs-string">"mysql -u root -h mysql --password=root database &lt; database_dump.sql"</span></code></span></pre>


<p>This will execute the application image and import the data with the mysql client which connects to the host <code>mysql</code> which is the linked mysql container.</p>



<h2 class="wp-block-heading">3. Use phpmyadmin in docker-compose setup</h2>



<p>If the above is too consolish then you also can just add a phpmyaadmin container in your docker-compose setup and administer the database with a GUI from the browser.</p>


<pre class="wp-block-code"><span><code class="hljs">  myproject_phpmyadmin:
	image: phpmyadmin/phpmyadmin:latest
	ports:
	  - 8080:80
	environment:
	  PMA_HOST: myproject_mysql</code></span></pre>


<p>Then you can just open <em>http://localhost:8080</em> in the browser and log into to Phpmyadmin.<br />To import data go to the import tab and upload the dump file.</p>



<figure class="wp-block-image size-full"><a href="https://nerdpress.org/wp-content/uploads/2023/02/phpmyadmin_import_tab.png"><img decoding="async" width="481" height="51" src="https://nerdpress.org/wp-content/uploads/2023/02/phpmyadmin_import_tab.png" alt="" class="wp-image-3222" srcset="https://nerdpress.org/wp-content/uploads/2023/02/phpmyadmin_import_tab.png 481w, https://nerdpress.org/wp-content/uploads/2023/02/phpmyadmin_import_tab-300x32.png 300w" sizes="(max-width: 481px) 100vw, 481px" /></a><figcaption class="wp-element-caption">PhpMyAdmin Import tab</figcaption></figure>



<h2 class="wp-block-heading">4. Using a mysql GUI client on the host and connect to the DB in the Docker container</h2>



<p>For this approach you just need to open a port in the database container to the outside and use this port with localhost in the settings of your database client.</p>


<pre class="wp-block-code"><span><code class="hljs language-php">  myproject_mysql:
    image: mysql:<span class="hljs-number">5.7</span>
    hostname: mysql.${DOMAIN}
    container_name: ${CONTAINER_NAME}.mysql
      volumes:
	- ${PWD}/data/mysql/:/<span class="hljs-keyword">var</span>/lib/mysql
	- ./container/mysql/my.cnf:/etc/mysql/conf.d/z_my.cnf
    ports: <span class="hljs-comment"># open the mysql port to the host</span>
      - <span class="hljs-string">"3306:3306"</span>
    environment:
  ...</code></span></pre>


<p>See this screenshot from IntellIj&#8217;s PHPStorm Database tool:</p>



<figure class="wp-block-image size-full"><a href="https://nerdpress.org/wp-content/uploads/2023/02/PHPStorm_Database_property.png"><img fetchpriority="high" decoding="async" width="807" height="491" src="https://nerdpress.org/wp-content/uploads/2023/02/PHPStorm_Database_property.png" alt="" class="wp-image-3223" srcset="https://nerdpress.org/wp-content/uploads/2023/02/PHPStorm_Database_property.png 807w, https://nerdpress.org/wp-content/uploads/2023/02/PHPStorm_Database_property-300x183.png 300w, https://nerdpress.org/wp-content/uploads/2023/02/PHPStorm_Database_property-768x467.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></a><figcaption class="wp-element-caption">PHPStorm DB settings</figcaption></figure>



<p>From my experience these clients are very good to check data but not so good for import, at least I had rather poor experience in the PHPStorm DB Tool.<br />So going consolish on imports is recommended :)</p>The post <a href="https://nerdpress.org/2023/02/24/import-data-into-mysql-with-docker-compose/">Import data into MySql with docker-compose</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Show kubernetes secrets with k9s</title>
		<link>https://nerdpress.org/2022/10/14/show-kubernetes-secrets-with-k9s/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Fri, 14 Oct 2022 09:07:10 +0000</pubDate>
				<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[k9s]]></category>
		<category><![CDATA[kubernetes]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=3176</guid>

					<description><![CDATA[<p>If you want to show decrypted secrets of your kubernetes (k8s) deployment with k9s try this: First choose the namespace you want to check the secrets in by typing a colon and namespace Then choose your namespace by navigating with your arrow down key and press return when on the desired namespace. Then type a &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2022/10/14/show-kubernetes-secrets-with-k9s/" class="more-link">Continue reading<span class="screen-reader-text"> "Show kubernetes secrets with k9s"</span></a></p>
The post <a href="https://nerdpress.org/2022/10/14/show-kubernetes-secrets-with-k9s/">Show kubernetes secrets with k9s</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>If you want to show decrypted <a href="https://kubernetes.io/docs/concepts/configuration/secret/" target="_blank" rel="noreferrer noopener" title="https://kubernetes.io/docs/concepts/configuration/secret/">secrets</a> of your kubernetes (k8s) deployment with <a href="https://k9scli.io/" target="_blank" rel="noreferrer noopener">k9s</a> try this:</p>



<p>First choose the namespace you want to check the secrets in by typing a colon and  <em>namespace</em> </p>



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


<pre class="wp-block-code"><span><code class="hljs language-shell">:namespace</code></span></pre>


<p>Then choose your namespace by navigating with your arrow down key and press return when on the desired namespace.</p>



<p>Then type a colon and type &#8216;secrets&#8217;:</p>


<pre class="wp-block-code"><span><code class="hljs language-shell">:secrets</code></span></pre>


<p>Then choose your secret by navigating with your arrow down key and press return when on the desired secret.</p>



<p>When secret is selected press <strong>x</strong> and k9s will display the decrypted secrets.</p>



<figure class="wp-block-image size-full"><a href="https://nerdpress.org/wp-content/uploads/2022/10/k9s-show-secrets-1.png"><img decoding="async" width="319" height="131" src="https://nerdpress.org/wp-content/uploads/2022/10/k9s-show-secrets-1.png" alt="" class="wp-image-3180" srcset="https://nerdpress.org/wp-content/uploads/2022/10/k9s-show-secrets-1.png 319w, https://nerdpress.org/wp-content/uploads/2022/10/k9s-show-secrets-1-300x123.png 300w" sizes="(max-width: 319px) 100vw, 319px" /></a><figcaption>k9s decode secrets with x</figcaption></figure>



<p>Leave the decrypted display again by pressing Escape key.</p>The post <a href="https://nerdpress.org/2022/10/14/show-kubernetes-secrets-with-k9s/">Show kubernetes secrets with k9s</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Docker-compose and Unknown MySQL server host</title>
		<link>https://nerdpress.org/2020/12/08/docker-compose-and-unknown-mysql-server-host/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Tue, 08 Dec 2020 10:06:25 +0000</pubDate>
				<category><![CDATA[docker]]></category>
		<category><![CDATA[docker-compose]]></category>
		<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2962</guid>

					<description><![CDATA[<p>In case you encounter this error with mysql and your docker-compose setup: &#8230; and you dont know why because everything seems to be correct. Then you might have an upgrade problem with mysql because you are reusing an old volume that was created for another mysql version.This can happen when you use a unspecified tag &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2020/12/08/docker-compose-and-unknown-mysql-server-host/" class="more-link">Continue reading<span class="screen-reader-text"> "Docker-compose and Unknown MySQL server host"</span></a></p>
The post <a href="https://nerdpress.org/2020/12/08/docker-compose-and-unknown-mysql-server-host/">Docker-compose and Unknown MySQL server host</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>In case you encounter this error with mysql and your docker-compose setup:</p>


<pre class="wp-block-code"><span><code class="hljs language-xml">Unknown MySQL server host <span class="hljs-tag">&lt;<span class="hljs-name">mysql-service-name</span>&gt;</span></code></span></pre>


<p>&#8230; and you dont know why because everything seems to be correct.</p>



<p>Then you might have an upgrade problem with mysql because you are reusing an old volume that was created for another mysql version.<br>This can happen when you use a unspecified tag as <code>mysql:latest</code> (not recommended anyway) and there was a version bump in the official mysql image. <br>Or you upgraded the mysql container yourself, f.e. from <code>mysql:5.6</code> to <code>mysql:5.7</code> and you are reusing the data volume with the mysql files.</p>



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



<p>When you check the startup logs you might see that mysql container is shutting down after startup because of an error like this:</p>


<pre class="wp-block-code"><span><code class="hljs">Can't open the mysql.plugin table. Please run mysql_upgrade to create it.</code></span></pre>


<p>You can run the upgrade command in the container:</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript">docker exec -it mysql_container_name bash -c <span class="hljs-string">"mysql_upgrade -uroot -proot"</span></code></span></pre>


<p>Or simply delete the volume and recreate it.<br><em>Note: the data will unfortunatly be lost. So better dump the data before deleting the volume and reimport it.</em><br>In my case its no problem because im starting a new project anyway.</p>



<p>To delete the volume you can:</p>


<pre class="wp-block-code"><span><code class="hljs language-xml">docker volume rm <span class="hljs-tag">&lt;<span class="hljs-name">volume</span> <span class="hljs-attr">id</span>&gt;</span></code></span></pre>


<p>Or just delete the data dir:</p>


<pre class="wp-block-code"><span><code class="hljs">rm -rf ./data/mysql</code></span></pre>


<p>Then restart your setup so the mysql container recreates the databases:</p>


<pre class="wp-block-code"><span><code class="hljs">docker-compose up</code></span></pre>


<p>and mysql is working again and the application is able to connect. :)</p>The post <a href="https://nerdpress.org/2020/12/08/docker-compose-and-unknown-mysql-server-host/">Docker-compose and Unknown MySQL server host</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>docker-compose network not found</title>
		<link>https://nerdpress.org/2020/01/27/docker-compose-network-not-found/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Mon, 27 Jan 2020 10:22:17 +0000</pubDate>
				<category><![CDATA[docker]]></category>
		<category><![CDATA[docker-compose]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2903</guid>

					<description><![CDATA[<p>Recently i more often encounter this strange error in my docker-compose setups while bringing up the containers with docker-compose up: ERROR: for docker_myproject_phpmyadmin_1 Cannot start service mg_myproject_phpmyadmin: network 15dff95a23808fe9d14b3dae71c0daeaa8b274c90566baa5beff37f3738033b6 not found For some reason the networks were deleted and docker-compose doesnt automatically recreate networks unless you tell so by forcing docker to recreate containers: docker-compose &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2020/01/27/docker-compose-network-not-found/" class="more-link">Continue reading<span class="screen-reader-text"> "docker-compose network not found"</span></a></p>
The post <a href="https://nerdpress.org/2020/01/27/docker-compose-network-not-found/">docker-compose network not found</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>Recently i more often encounter this strange error in my docker-compose setups while bringing up the containers with <code>docker-compose up</code>:</p>



<p><code>ERROR: for docker_myproject_phpmyadmin_1  Cannot start service mg_myproject_phpmyadmin: network 15dff95a23808fe9d14b3dae71c0daeaa8b274c90566baa5beff37f3738033b6 not found</code></p>



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



<p>For some reason the networks were deleted and docker-compose doesnt automatically recreate networks unless you tell so by forcing docker to recreate containers:</p>



<p><code>docker-compose up --force-recreate</code></p>



<p>Solution came from this issue:<br /> <a href="https://github.com/docker/compose/issues/5745#issuecomment-370031631">https://github.com/docker/compose/issues/5745#issuecomment-370031631</a></p>



<p>Probably i have to explicitly declare the networks to prevent mixups between projects.<br />Though i thought this would not be necessary&#8230;</p>The post <a href="https://nerdpress.org/2020/01/27/docker-compose-network-not-found/">docker-compose network not found</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Adminer for Sqlite in Docker</title>
		<link>https://nerdpress.org/2019/10/23/adminer-for-sqlite-in-docker/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Wed, 23 Oct 2019 08:02:47 +0000</pubDate>
				<category><![CDATA[docker]]></category>
		<category><![CDATA[Sqlite]]></category>
		<category><![CDATA[adminer]]></category>
		<category><![CDATA[docker-compose]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2889</guid>

					<description><![CDATA[<p>Recently i wanted to use Sqlite with Adminer in Docker and it turned out to be not so easy. I actually thought i could just declare Adminer in a docker-compose.yml file with a volume mounted, similar as i would do for adminer with mysql. Update: Today i would rather use the IntelliJ Database Tool for &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2019/10/23/adminer-for-sqlite-in-docker/" class="more-link">Continue reading<span class="screen-reader-text"> "Adminer for Sqlite in Docker"</span></a></p>
The post <a href="https://nerdpress.org/2019/10/23/adminer-for-sqlite-in-docker/">Adminer for Sqlite in Docker</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>Recently i wanted to use Sqlite with <a aria-label="Adminer (opens in a new tab)" href="https://www.adminer.org/" target="_blank" rel="noreferrer noopener">Adminer</a> in Docker and it turned out to be not so easy.<br /> I actually thought i could just declare Adminer in a docker-compose.yml file with a volume mounted, similar as i would do for adminer with mysql.</p>



<p><strong>Update</strong>: Today i would rather use the <a href="https://nerdpress.org/2021/05/17/sqlite-administration-in-intellij-ide/">IntelliJ Database Tool for Sqlite administration</a>.</p>



<p>But since Adminer is a popular hacking target they introduced a <a href="https://www.adminer.org/en/password/" target="_blank" rel="noreferrer noopener" aria-label="feature (opens in a new tab)">feature</a> that does not allow to run adminer without a password, out of the box.<br /> Sqlite database usually runs without password and dang, workaround needed!</p>



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



<p>So we need to add a plugin to adminer that allows password-less login and extend the official Adminer Docker image to include the plugin.</p>



<p>We add a script that loads the official password-less-login plugin and copy it to the plugins-enabled folder of the Adminer image</p>



<p>login-password-less.php:</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:100%"><div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
&lt;?php
require_once(&#039;plugins/login-password-less.php&#039;);

/** Set allowed password
 * @param string result of password_hash
 */
return new AdminerLoginPasswordLess(
    $password_hash = password_hash(&quot;admin&quot;, PASSWORD_DEFAULT)
);
</pre></div></div>
</div>



<p>Dockerfile:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
FROM adminer
USER root
COPY login-password-less.php /var/www/html/plugins-enabled/login-password-less.php
#USER adminer # we run as root because of permissions problems on db file with the volume
</pre></div>


<p>In docker-compose.yml:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: yaml; title: ; notranslate">
version: &quot;3&quot;
services:
  app:
    build: ./php
      - mailcatcher
    volumes:
      - &quot;../:/app:rw&quot;
      - &quot;./php/cli/php.ini:/etc/php/7.3/cli/php.ini:ro&quot;
      - &quot;./php/fpm/php.ini:/etc/php/7.3/fpm/php.ini:ro&quot;

  nginx:
    build: ./nginx
    depends_on:
      - app
    command: /bin/sh -c &quot;nginx -g &#039;daemon off;&#039;&quot;
    volumes:
      - &quot;..:/app:rw&quot;
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
    ports:
      - &#039;8088:80&#039;

  adminer:
    build: ./adminer
    restart: unless-stopped
    volumes:
      - &quot;..:/app:rw&quot;
    ports:
      - 8080:8080
</pre></div>


<p>File tree:</p>



<ul class="wp-block-list"><li>adminer<br />&#8211; Dockerfile<br />&#8211; login-password-less.php</li><li>nginx<br />&#8230;</li><li>php<br />&#8230;</li><li>docker-compose.yml</li></ul>



<p><em>Note that since docker-compose.yml version 3 the volumes_from directive was removed in favor of top level volumes to share volumes across images. However this implementation is imho rather weird, so i jut duplicated the volumes declaration in the App container and Adminer container.<br /> Feels rather wrong but thats all i could come up with. Any advice here is welcome.</em></p>



<p>Now that this is done we can open the Sqlite3 database with the pseudo-password &#8220;admin&#8221; and manage the database.</p>



<p>After all you could also just copy the one-file Adminer with plugin to the php container and run it from within the php container. Just adjust your Nginx config to allow calling the file directly and take care to not deploy Adminer to live.<br /> There is also a project that bundles the plugin with Adminer to one file: <a href="https://github.com/FrancoisCapon/LoginToASqlite3DatabaseWithoutCredentialsWithAdminer" target="_blank" rel="noreferrer noopener">https://github.com/FrancoisCapon/LoginToASqlite3DatabaseWithoutCredentialsWithAdminer/blob/master/build-adminer-4-sqlite3-into-one-file.sh</a></p>The post <a href="https://nerdpress.org/2019/10/23/adminer-for-sqlite-in-docker/">Adminer for Sqlite in Docker</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>
		<item>
		<title>Symfony development with docker on a mac</title>
		<link>https://nerdpress.org/2016/05/07/symfony-development-docker-mac/</link>
					<comments>https://nerdpress.org/2016/05/07/symfony-development-docker-mac/#comments</comments>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Sat, 07 May 2016 18:04:52 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Project Setup]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[mac]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2681</guid>

					<description><![CDATA[<p>I recently started to do all PHP development with docker, since I was just tired of installing tons of dev libraries on my machine. Most of which i couldn&#8217;t even remember what they actually were good for. When I first tried docker (docker-toolbox for mac) I was really disappointed how slow symfony apps ran inside &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2016/05/07/symfony-development-docker-mac/" class="more-link">Continue reading<span class="screen-reader-text"> "Symfony development with docker on a mac"</span></a></p>
The post <a href="https://nerdpress.org/2016/05/07/symfony-development-docker-mac/">Symfony development with docker on a mac</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>I recently started to do all PHP development with docker, since I was just tired of installing tons of dev libraries on my machine. Most of which i couldn&#8217;t even remember what they actually were good for.</p>
<p>When I first tried docker (docker-toolbox for mac) I was really disappointed how slow symfony apps ran inside the container.<span id="more-2681"></span></p>
<p>I did a bit of research (didn&#8217;t completely get it though)  &#8211; but most of the speed issues that people experience seem to be related to the rather slow file system access in mounted folders.</p>
<p>That&#8217;s where <a href="https://github.com/nlf/dlite">dlite</a> really shines.<br />
It&#8217;s an app that uses <a href="https://github.com/nlf/dlite#thanks">some sort of alternative</a> to virtualbox etc. which has significant speed advantages.</p>
<p>I highly recommend you give it a try if you&#8217;re developing with docker in OSX.<br />
Installation with <a href="http://brew.sh/">homebrew</a> is quite simple:</p>
<pre class="brush: bash; title: ; notranslate">
brew install dlite
dlite stop &amp;&amp; dlite update -v 2.3.0 &amp;&amp; dlite start
brew install docker
brew install docker-compose
</pre>
<p>Another thing I found quite challenging was setting up permissions when running symfony inside docker.<br />
I found a couple of tutorials on that but none of those seemed to really work with my setup.</p>
<p>You could use data containers for the cache and log folders and don&#8217;t have any <a href="http://stackoverflow.com/questions/34949083/symfony-docker-permission-problems-for-cache-files">permission problems</a>.<br />
Or just use some internal folder `/tmp/myapp/cache` or `/dev/shm/myapp` (the latter really is fast&#8230;).</p>
<p>But any of those approaches will make it difficult to access the cache files from the host.<br />
(I use PHPStorm with the symfony plugin, which relies on parsing some cache files)<br />
It also doesn&#8217;t solve the problem of persmissions for the `/web` folders, when installing assets or write to any data folders you also wan&#8217;t to mount from the host filesystem.</p>
<p>I have not found a really elegant solution for that, but there&#8217;s a workaround which does work magic:</p>
<p>You can set uid of the www-data inside the container your host users&#8217; uid.<br />
Something like `RUN usermod -u 501 www-data` inside your webserver Dockerfile should do the trick for your default user on mac. You can then log into the container and run symfony commands as www-data and have no problems with accessing files from host filesystem, command-line or the webserver.</p>
<p><a href="https://nerdpress.org">W</a><a href="https://www.facebook.com/sonntagnacht">e</a> put together a docker setup for symfony development, which should work across different operating systems.</p>
<p><a href="https://github.com/nerdpress-org/docker-sf3/">https://github.com/nerdpress-org/docker-sf3/</a></p>
<p>So as a quickstart, after installing docker &#038; dlite just run:</p>
<pre class="brush: bash; title: ; notranslate">
git clone https://github.com/nerdpress-org/docker-sf3.git docker-sf3
cp -r docker-sf3/docker /path/to/your/symfony-project/
cd /path/to/your/symfony-project/docker
sh ./docker.sh -l
</pre>The post <a href="https://nerdpress.org/2016/05/07/symfony-development-docker-mac/">Symfony development with docker on a mac</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
					<wfw:commentRss>https://nerdpress.org/2016/05/07/symfony-development-docker-mac/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>git deploy with composer install hook</title>
		<link>https://nerdpress.org/2014/11/14/git-deploy-composer-install-hook/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Fri, 14 Nov 2014 07:51:00 +0000</pubDate>
				<category><![CDATA[Composer]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[composer]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[Git]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2572</guid>

					<description><![CDATA[<p>I usually would not recommend deployment via git and running composer on your prod server for several reasons like f.e. the network. I rather believe in builds. But sometimes its just too convenient :) So i have this uncritical smaller API app where the hosting has git, ssh access and i am in full control &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2014/11/14/git-deploy-composer-install-hook/" class="more-link">Continue reading<span class="screen-reader-text"> "git deploy with composer install hook"</span></a></p>
The post <a href="https://nerdpress.org/2014/11/14/git-deploy-composer-install-hook/">git deploy with composer install hook</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>I usually would not recommend deployment via git and running <a href="https://getcomposer.org/">composer</a> on your prod server for several reasons like f.e. the network. I rather believe in builds.<br />
But sometimes its just too convenient :)</p>
<p>So i have this uncritical smaller API app where the hosting has git, ssh access and i am in full control and i decided too keep it simple.<br />
<span id="more-2572"></span></p>
<p>For deploy i login via ssh and make a <strong>git pull</strong> too fetch the code.<br />
Now we need to make a <strong>composer install</strong>, if the composer.lock has changes to fetch all php dependencies.<br />
Therefor i found a handy bash script, tweaked it a bit and installed it as post-merge git hook.</p>
<p>Install the hook:</p>
<pre class="brush: bash; title: ; notranslate">
cd project
nano .git/hooks/post-merge #paste &amp; edit the script
chmod 775 .git/hooks/post-merge 
</pre>
<p>What it does?<br />
After all code from the <strong>git pull</strong> is merged into the working tree, the hook checks if the composer.lock has changed. If so it will run a <strong>composer install</strong>.<br />
Note that it runs with <strong>&#8211;no-dev</strong> since we are on production and dont need f.e. phpunit there.</p>
<p>I know you know, but let it be said again: run <strong>composer install</strong> not <strong>composer update</strong>, as you never should run composer update on production, read why <a href="http://adamcod.es/2013/03/07/composer-install-vs-composer-update.html">here</a>.</p>
<p>So here is the bash:</p>
<pre class="brush: bash; title: ; notranslate">
#/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# forked by Gianluca Guarini
# phponly by Ivo Bathke ;)
 
changed_files=&quot;$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)&quot;
 
check_run() {
  echo &quot;$changed_files&quot; | grep --quiet &quot;$1&quot; &amp;&amp; eval &quot;$2&quot;
}
 
# `composer install` if the `composer.lock` file gets changed
# to update all the php dependencies
check_run composer.lock &quot;composer install --no-dev&quot;
</pre>
<p>I <a href="https://gist.github.com/ivoba/6dcdff1d8eaed7e53ec6">forked</a> it from <a href="https://gist.github.com/GianlucaGuarini/8001627">here</a>, that forked from <a href="https://gist.github.com/sindresorhus/7996717">there</a>.</p>The post <a href="https://nerdpress.org/2014/11/14/git-deploy-composer-install-hook/">git deploy with composer install hook</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Symfony2 Starter Tweaks</title>
		<link>https://nerdpress.org/2012/05/23/symfony2-starter-tweaks/</link>
					<comments>https://nerdpress.org/2012/05/23/symfony2-starter-tweaks/#comments</comments>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Wed, 23 May 2012 14:32:10 +0000</pubDate>
				<category><![CDATA[Project Setup]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Symfony2]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2186</guid>

					<description><![CDATA[<p>When you start with symfony you probably use the Symfony Standard Edition. This is a quite good start but there are somethings that helped me and might help you aswell. Since every beginning is &#8220;schwer&#8221; :) So here there are. 1. replace web/app*.dev with the following index.php its much nicer to use the DirectoryIndex in &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2012/05/23/symfony2-starter-tweaks/" class="more-link">Continue reading<span class="screen-reader-text"> "Symfony2 Starter Tweaks"</span></a></p>
The post <a href="https://nerdpress.org/2012/05/23/symfony2-starter-tweaks/">Symfony2 Starter Tweaks</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>When you start with symfony you probably use the <a href="https://github.com/symfony/symfony-standard">Symfony Standard Edition</a>.<br />
This is a quite good start but there are somethings that helped me and might help you aswell.<br />
Since every beginning is &#8220;schwer&#8221; :)<br />
So here there are.<br />
<span id="more-2186"></span><br />
<strong>1. replace web/app*.dev with the following index.php</strong><br />
<script src="https://gist.github.com/2775189.js"></script><noscript><pre><code class="language-php php">&lt;?php
/**
* Tweaked Symfony2 bootstrap file
*/

// if you don&#039;t want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
umask(0000);

if ( file_exists( dirname(__FILE__).&#039;/../.env.php&#039; ) ){
    $env = require_once( dirname(__FILE__).&#039;/../.env.php&#039; );
}
$env = isset( $env )? $env : &#039;prod&#039;;
$debug = true;
if($env == &#039;prod&#039;){
	$debug = false;
}

require_once __DIR__.&#039;/../app/bootstrap.php.cache&#039;;
require_once __DIR__.&#039;/../app/AppKernel.php&#039;;

use Symfony\Component\HttpFoundation\Request;

$kernel = new AppKernel($env, $debug);
$kernel-&gt;loadClassCache();
if( $env != &#039;dev&#039; ){
//require_once __DIR__.&#039;/../app/AppCache.php&#039;;
//$kernel = new AppCache($kernel);
}
$request = Request::createFromGlobals();
$response = $kernel-&gt;handle($request);
$response-&gt;send();
$kernel-&gt;terminate($request, $response);
</code></pre></noscript></p>
<p>its much nicer to use the DirectoryIndex in your URL and not having the web_app.php, thats the aesthetics.<br />
But it also avoids having some hassle with ajax urls which are defined absolute in some scripts like<br />
url: /myajax/call.json</p>
<p>The Environment can be changed in the .env.php file which just returns the Environment value:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
return $env = 'dev';
</pre>
<p>Personally i dont mind changing the Env in the code rather than in the url, while in development.<br />
It might be a tick more far away but its rather uncommon anyway and it would be more effort to change the vhost DirectoryIndex on web_dev.php and prod everytime to get a clean url.<br />
<em>(thanks max &#038; joshi)</em></p>
<p><strong>2. resolve console and webserver user conflict for cache</strong><br />
Different to Symfony 1.x Symfony2 assumes a more sophisticated User Managment on your machine for Security reasons, which absolutly makes sense. Read more about it here:<a href="http://symfony.com/doc/current/book/installation.html#configuration-and-setup">http://symfony.com/doc/current/book/installation.html#configuration-and-setup</a><br />
This means you have to adjust the rights for the webserver- and for the console user that both can create and delete the cache.<br />
This requires some admin skills which might be a bit too much for starters.<br />
And some people start wondering why the </p>
<pre class="brush: bash; title: ; notranslate">php app/console cache:clear</pre>
<p>command wont work and start using </p>
<pre class="brush: bash; title: ; notranslate">rm -rf app/cache/*</pre>
<p>in desperation. </p>
<p>To fix this Symfony2 recommends as a &#8216;hotfix&#8217; to uncomment the </p>
<pre class="brush: php; title: ; notranslate">umask(0000);</pre>
<p>part on top of your bootstrap files.<br />
So simply uncomment the line in app_dev.php ( <em>if you use the one from above its already done :)</em> ) and in <em>app/console</em>.<br />
Thats alright for local setup, for production go and talk to your admin of trust or live the life of adventure.</p>
<p><strong>3. make a local config that can be placed in gitignore</strong><br />
Here you can store config parameters and overwrite common ones to fit your local setup. Put it in the gitignore so your fellow devs can do the same.<br />
Therefor we need to hack the AppKernel.php and redefine the registerContainerConfiguration method like so.<br />
<script src="https://gist.github.com/2775277.js"></script><noscript><pre><code class="language-php php">public function registerContainerConfiguration(LoaderInterface $loader) {

        if ($this-&gt;getEnvironment() == &#039;dev&#039;) {
            $extrafiles = array(
                __DIR__ . &#039;/config/config_local.yml&#039;,
            );
            foreach ($extrafiles as $filename) {
                if (file_exists($filename) &amp;&amp; is_readable($filename)) {
                    $loader-&gt;load($filename);
                }
            }
        } else {
            $loader-&gt;load(__DIR__ . &#039;/config/config_&#039; . $this-&gt;getEnvironment() . &#039;.yml&#039;);
        }
}</code></pre></noscript></p>
<p>Read more about it:<br />
<a href="http://stackoverflow.com/questions/7338767/can-i-include-an-optional-config-file-in-symfony2/10336451#10336451">http://stackoverflow.com/questions/7338767/can-i-include-an-optional-config-file-in-symfony2/10336451#10336451</a></p>
<p>Now have fun with bundles &#038; services.</p>The post <a href="https://nerdpress.org/2012/05/23/symfony2-starter-tweaks/">Symfony2 Starter Tweaks</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
					<wfw:commentRss>https://nerdpress.org/2012/05/23/symfony2-starter-tweaks/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
