{"id":3788,"date":"2019-05-24T15:06:55","date_gmt":"2019-05-24T15:06:55","guid":{"rendered":"http:\/\/myramidnight.com\/?p=3788"},"modified":"2021-04-25T22:41:39","modified_gmt":"2021-04-25T22:41:39","slug":"experimenting-with-drupal8","status":"publish","type":"post","link":"https:\/\/myramidnight.com\/journal\/?p=3788","title":{"rendered":"Experimenting with Drupal8"},"content":{"rendered":"<p>I've wanted to get into Drupal since I got introduced to it during my short (2week) internship, so I'm going to write some notes here along the way while I try to setup a project.<\/p>\n<p>I was told that Drupalize.me was a great place to learn about Drupal, but I want to see how far I can get without paying for such a subscription (and they have a discount for students, I might apply for that when University starts after the summer).<\/p>\n<p>I also found this interesting list of <a href=\"https:\/\/thoughts.duoconsulting.com\/blog\/5-reasons-to-use-drupal-vs.-wordpress\">5 reasons to use Drupal v.s WordPress<\/a>&nbsp;while I was experimenting.<\/p>\n\n\n<h2>Let's use the terminal...<\/h2>\n\n\n\n<p>Even if using the terminal to manage things was intimidating at first, I would much prefer to use it for project than installers, because I like keeping things as bare-bones as possible when I'm really trying to figure out how it works, GUI installers always give me the impression that it'll come with extra junk I wouldn't use or understand how it's relevant. <\/p>\n\n\n\n<p>And the guy who gave me the intro into Drupal8 (Hilmar K\u00e1ri, freelance programmer) much preferred to use the terminal for everything when possible. <\/p>\n\n\n\n<p>But I really dislike using the Windows PowerShell, because apparently you can pause whatever it's doing by clicking the window, which can be pretty annoying when there is no indication that you accidentally paused it and are left waiting or anything running in that window isn't doing what it should). <\/p>\n\n\n\n<p>I only use it to start projects, after that I have the option to use the inbuilt terminal of Visual Studio Code, which is quite handy and doesn't pause accidentally.<\/p>\n\n\n\n<h3>Using Composer to install Drupal8<\/h3>\n\n\n\n<p>Drupal has a guide on <a href=\"https:\/\/www.drupal.org\/docs\/develop\/using-composer\/using-composer-to-install-drupal-and-manage-dependencies\" rel=\"noreferrer noopener\" target=\"_blank\">how to install the CMS using Composer<\/a><\/p>\n\n\n\n<p><em>Composer <\/em>is for PHP what <em>npm <\/em>or <em>yarn <\/em>is for JavaScript, but I'll admit that I've never really used it before, I installed it sometime ago for another project that I didn't actually get into, but now I have a chance to use it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>composer create-project drupal-composer\/drupal-project:8.x-dev my_site_name_dir --no-interaction<\/code><\/pre>\n\n\n\n<p>This command will download the files and create a new directory containing our drupal installation. You can change the my_site_name_dir into whatever you wish, and if you don't want it to automatically install then adding <code>--no-install<\/code> at the end will prevent that (running <code>composer install<\/code><em> <\/em>will let you manually install it after you've made whatever changes to the installation that you required for the project)<\/p>\n\n\n\n<h3>First obstacle: memory_limit while installing<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 32 bytes) in phar:\/\/C:\/composer\/... \/Constraint.php on line 182<\/code><\/pre>\n\n\n\n<p>The default memory limit for composer seems to be 128M, and apparently it is a common issue for developers when using Composer for Drupal8 (because Composer seems to need lots of memory). There is a <a href=\"https:\/\/getcomposer.org\/doc\/articles\/troubleshooting.md#memory-limit-errors\">troubleshoot guide on the composer website<\/a> that covers this issue, even the error message gives you the link. <\/p>\n\n\n\n<p>The directions on the Composer website weren't solving the issue for me, maybe I'm not deep enough in the programming know-hows yet, but I did find a <a href=\"https:\/\/www.chapterthree.com\/blog\/how-fix-composer-memory-issue\">very easy to understand explanation and solution to the memory issue<\/a>. To easily find location of the file you need to edit just run <em><code>php --ini<\/code><\/em> in the terminal, then simply open that file in your favorite editor and increase the <em>memory_limit <\/em>(setting it to -1 will make it unlimited).<\/p>\n\n\n\n<h3>Simple PHP server to view in localhost<\/h3>\n\n\n\n<p>You can actually view your PHP project in browser even if you only have PHP installed on your system, because it has a <a href=\"https:\/\/www.php.net\/manual\/en\/features.commandline.webserver.php\">inbuilt command that starts up a PHP server<\/a>. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd web\nphp -S localhost:8000 <\/code><\/pre>\n\n\n\n<p>As such, there is no real need WAMP\/MAMP or other such server setups just for displaying PHP in development, but they do make things convenient and create a full server locally with database and other things (as far as I'm aware)<\/p>\n\n\n\n<h3>Seems that my PHP version is&nbsp;outdated<\/h3>\n\n\n\n<p>When going through the final setup (in localhost) I discovered that my PHP version was outdated (5.x) which was actually supplied by my WAMP server. The <a href=\"https:\/\/www.drupal.org\/docs\/8\/system-requirements\/php-requirements\" rel=\"noreferrer noopener\" target=\"_blank\">recomended version of PHP<\/a> is 7.2 as of Drupal8.5, and apparently the support for PHP5 ended with Drupal8.7<\/p>\n\n\n\n<p>I have come to realize it doesn\u2019t really matter where you keep the folder containing the code, just need to add it to the System Environment Variables Path (I\u2019m using win10, in case you were wondering). Ended up uninstalling WAMP (because it didn\u2019t occur to me to update it) and getting XAMPP that contained the version of PHP that I needed, and then proceeded to add it\u2019s PHP folder to the system paths. My experiment with downloading the code directly from PHP wasn\u2019t working out even with restarts of the computer.<\/p>\n\n\n\n<p>I have to do the whole memory_limit thing all over again now\u2026<\/p>\n\n\n\n<h3>Now I just need to connect a&nbsp;database<\/h3>\n\n\n\n<p>I did mention that I installed XAMPP server, it comes with a MySQL database which I\u2019ll be using. The default access to the database has no password which seems to be quite common for a development server, but of course it should be more secure than that when things go into production.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">username: root<br>password:<\/pre>\n\n\n\n<p>I created a new table for the project through phpMyAdmin and went through the installation process from localhost:8000 and just chose the default as a beginner, everything went smoothly and now I can start developing a website with Drupal8.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve wanted to get into Drupal since I got introduced to it during my short (2week) internship, so I&#8217;m going to write some notes here along the way while I try to setup a project. I was told that Drupalize.me was a great place to learn about Drupal, but I want to see how far &hellip; <a href=\"https:\/\/myramidnight.com\/journal\/?p=3788\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Experimenting with Drupal8<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[178],"tags":[],"_links":{"self":[{"href":"https:\/\/myramidnight.com\/journal\/index.php?rest_route=\/wp\/v2\/posts\/3788"}],"collection":[{"href":"https:\/\/myramidnight.com\/journal\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myramidnight.com\/journal\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myramidnight.com\/journal\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myramidnight.com\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3788"}],"version-history":[{"count":21,"href":"https:\/\/myramidnight.com\/journal\/index.php?rest_route=\/wp\/v2\/posts\/3788\/revisions"}],"predecessor-version":[{"id":3832,"href":"https:\/\/myramidnight.com\/journal\/index.php?rest_route=\/wp\/v2\/posts\/3788\/revisions\/3832"}],"wp:attachment":[{"href":"https:\/\/myramidnight.com\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myramidnight.com\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myramidnight.com\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}