<?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>PHPStorm | Nerdpress.org</title>
	<atom:link href="https://nerdpress.org/tag/phpstorm/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerdpress.org</link>
	<description>...dev, tech problems and solutions.</description>
	<lastBuildDate>Fri, 24 Feb 2023 10:04:31 +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>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>Directories settings in PHPStorm and IntelliJ Ultimate</title>
		<link>https://nerdpress.org/2018/12/29/directories-settings-in-phpstorm-and-intellij-ultimate/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Sat, 29 Dec 2018 10:30:46 +0000</pubDate>
				<category><![CDATA[IDE]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[IntelliJ Ultimate]]></category>
		<category><![CDATA[PHPStorm]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2840</guid>

					<description><![CDATA[<p>I recently switched from PHPStorm to IntelliJ Ultimate because of some Java. But still i am working a lot on PHP and symfony projects. One thing i usually do on symfony projects in PHPStorm is to edit the &#8220;Directories&#8221; in the settings to avoid having results from var/cache or var/logs in the search results. Also &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2018/12/29/directories-settings-in-phpstorm-and-intellij-ultimate/" class="more-link">Continue reading<span class="screen-reader-text"> "Directories settings in PHPStorm and IntelliJ Ultimate"</span></a></p>
The post <a href="https://nerdpress.org/2018/12/29/directories-settings-in-phpstorm-and-intellij-ultimate/">Directories settings in PHPStorm and IntelliJ Ultimate</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>I recently switched from PHPStorm to IntelliJ Ultimate because of some Java. But still i am working a lot on PHP and symfony projects.</p>
<p>One thing i usually do on symfony projects in PHPStorm is to edit the <i>&#8220;Directories&#8221;</i> in the settings to avoid having results from <em>var/cache</em> or <em>var/logs</em> in the search results.</p>
<p>Also it slows down the search which i heavily use. So i exlude all folders that should not be searched because they are cache files or are redundant in some other way.</p>


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



<figure class="wp-block-image"><a href="https://nerdpress.org/wp-content/uploads/2018/12/Bildschirmfoto-vom-2018-12-29-10-48-51.png"><img decoding="async" width="1024" height="627" src="https://nerdpress.org/wp-content/uploads/2018/12/Bildschirmfoto-vom-2018-12-29-10-48-51-1024x627.png" alt="" class="wp-image-2843" srcset="https://nerdpress.org/wp-content/uploads/2018/12/Bildschirmfoto-vom-2018-12-29-10-48-51-1024x627.png 1024w, https://nerdpress.org/wp-content/uploads/2018/12/Bildschirmfoto-vom-2018-12-29-10-48-51-300x184.png 300w, https://nerdpress.org/wp-content/uploads/2018/12/Bildschirmfoto-vom-2018-12-29-10-48-51-768x470.png 768w, https://nerdpress.org/wp-content/uploads/2018/12/Bildschirmfoto-vom-2018-12-29-10-48-51.png 1920w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></a><figcaption>PHPStorm Directories Settings</figcaption></figure>



<p>See this <strong>SO</strong> post for further discussion: <a rel="noreferrer noopener" href="https://stackoverflow.com/questions/35654320/how-to-configure-directories-when-using-a-symfony-project-in-phpstorm" target="_blank">https://stackoverflow.com/questions/35654320/how-to-configure-directories-when-using-a-symfony-project-in-phpstorm</a></p>



<p>But in IntelliJ Ultimate its a bit different and it took me a bit to figure out.<br>Here the equivalent is located under <em>&#8220;Project Structure-&gt;Modules&#8221;</em>.<br>Here you can exclude Directories, set &#8220;test&#8221; and &#8220;source&#8221; folders.</p>



<figure class="wp-block-image"><a href="https://nerdpress.org/wp-content/uploads/2018/12/Bildschirmfoto-vom-2018-12-29-11-00-16.png"><img decoding="async" width="1024" height="627" src="https://nerdpress.org/wp-content/uploads/2018/12/Bildschirmfoto-vom-2018-12-29-11-00-16-1024x627.png" alt="" class="wp-image-2844" srcset="https://nerdpress.org/wp-content/uploads/2018/12/Bildschirmfoto-vom-2018-12-29-11-00-16-1024x627.png 1024w, https://nerdpress.org/wp-content/uploads/2018/12/Bildschirmfoto-vom-2018-12-29-11-00-16-300x184.png 300w, https://nerdpress.org/wp-content/uploads/2018/12/Bildschirmfoto-vom-2018-12-29-11-00-16-768x470.png 768w, https://nerdpress.org/wp-content/uploads/2018/12/Bildschirmfoto-vom-2018-12-29-11-00-16.png 1920w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></a><figcaption>IntelliJ Ultimate Modules settings</figcaption></figure>



<p>Also it seems settings are imported from PHPStorm settings already when using a former PHPStorm project in IntelliJ Ultimate. Nice :)</p>The post <a href="https://nerdpress.org/2018/12/29/directories-settings-in-phpstorm-and-intellij-ultimate/">Directories settings in PHPStorm and IntelliJ Ultimate</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
