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.
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).
I also found this interesting list of 5 reasons to use Drupal v.s WordPress while I was experimenting.
Let's use the terminal...
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.
And the guy who gave me the intro into Drupal8 (Hilmar Kári, freelance programmer) much preferred to use the terminal for everything when possible.
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).
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.
Using Composer to install Drupal8
Drupal has a guide on how to install the CMS using Composer
composer create-project drupal-composer/drupal-project:8.x-dev my_site_name_dir --no-interaction
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
--no-install at the end will prevent that (running
composer install will let you manually install it after you've made whatever changes to the installation that you required for the project)
First obstacle: memory_limit while installing
Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 32 bytes) in phar://C:/composer/... /Constraint.php on line 182
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 troubleshoot guide on the composer website that covers this issue, even the error message gives you the link.
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 very easy to understand explanation and solution to the memory issue. To easily find location of the file you need to edit just run
php --ini in the terminal, then simply open that file in your favorite editor and increase the memory_limit (setting it to -1 will make it unlimited).
Simple PHP server to view in localhost
You can actually view your PHP project in browser even if you only have PHP installed on your system, because it has a inbuilt command that starts up a PHP server.
php -S localhost:8000
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)
Seems that my PHP version is outdated
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 recomended version of PHP is 7.2 as of Drupal8.5, and apparently the support for PHP5 ended with Drupal8.7
I have come to realize it doesn’t really matter where you keep the folder containing the code, just need to add it to the System Environment Variables Path (I’m using win10, in case you were wondering). Ended up uninstalling WAMP (because it didn’t occur to me to update it) and getting XAMPP that contained the version of PHP that I needed, and then proceeded to add it’s PHP folder to the system paths. My experiment with downloading the code directly from PHP wasn’t working out even with restarts of the computer.
I have to do the whole memory_limit thing all over again now…
Now I just need to connect a database
I did mention that I installed XAMPP server, it comes with a MySQL database which I’ll 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.
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.