DARK MODE 

Posted on Monday, November 30, 2020 by

Create Instagram Clone with Laravel (Part 1): Getting Everything Ready

To up my skills, today I learn Laravel. I am completely new to this and honestly, I don't really like to work with cmd. But there are some things that even if you don't like, you still need to do it, right? Because this is challenging, I decided to write what I've learned so that I will not easily forget . Well, let's get into it! First and foremost, you need to download and install all of these:

Install:
  1. nodejs
  2. PHP (choose thread safe and version that's suitable for your OS)
  3. Composer
Installing those programs can be tricky sometimes especially to newbie because there's just so many dependencies and module. Like.. without this one thing, this other thing cannot work properly. For nodejs installation, I don't know how important it is but I did as what it suggested me, which is installing Python and Visual Studio Build Tools. For this, I read this doc and install Visual Studio Build Tools via cmd that was run as administrator, with the command npm install --global windows-build-tools . This will also install Python 2 version 2.7. Because Python 2 will not be maintained past 2020, I decided to uninstall it and install Python 3 from its official site instead. Or if you want the easiest way, just check the box when it ask whether to install those things automatically or not lol. I didn't check on it because Chocolatey sounds like a program that I will never use.


Another thing that you must take note is, you don't need to download PHP if your computer already install program like XAMPP or Wamp. This is due to those programs already have PHP that comes together when you install it. Check if there's PHP installed in your system is probably the wise thing to do first. Just run cmd, and write php --version . If you haven't add the PHP folder in the environment variable (you should!), you need to enter the folder where php.ini resides. Jump to this section to know how to add it to environment variable. If it's installed properly, the cmd should output the version number of your PHP. According to Laravel site, you need at least PHP 7.3 if you are using Laravel 8.


For learning Laravel, I decided to use the latest version of PHP which is 8.0 (if things get tough in the future, I might just use PHP 7 in XAMPP). Download is easy but there are some configurations that you must do. For this, I watch this tutorial. If you're more into reading than watching video, these are the steps that should be taken.
  1. Extract the .zip content of the file you've downloaded into a new folder. You could name anything but according to the video tutorial, he said it's best if you don't put any special characters. I named the folder php8x64 and it's located in E:/Program Files/Programming
  2. Make a copy of php.ini-development and rename it to php.ini


  3. Open php.ini in a text editor to make some modifications.
    • Find doc_root = and add the location of your root/project folder. In my case, E:/Work. So, it will become doc_root = "E:/Work"
    • Find extension_dir. Locate ext file that is in your php installation folder. In my case, extension_dir = "E:/Program Files/Programming/php8x64/ext"
    • Find ;cgi.fix_pathinfo=1 and change it to cgi.fix_pathinfo=0 (Mind the semicolon at the start of the word! Anything with semicolon in front is a comment)
    • Find ;extension=bz2 and remove all semicolon for bz2, curl, fileinfo gd, gettext, mbstring, mysqli, openssl, pdo_mysql, pdo_pgsql, pgsql, soap, sqlite3
    • Save
  4. Press Win key and search for "environment variable". Open it.
  5. Click on "Environment Variables..."
  6. Under "System Variables", find and select Path variable. Click "Edit..."
  7. Click "New" and put the path to your php folder. In my case, E:\Program Files\Programming\php8x64.
  8. Press OK
Done! To confirm, open cmd, and run command php --version .

To install Composer and Laravel, it's a lot easier than I thought. I watched this tutorial.
  1. Place composer.phar in a folder named "Composer". As for me, I placed it in E:/Program Files/Programming/Composer
  2. Create a new file named composer.bat
  3. Right click on the file to edit it. Insert  @php "%~dp0composer.phar" %* and save.
  4. Open environment variable setting
  5. Create new system variable with variable name COMPOSER_HOME and variable path to the destination of where composer.phar resides. Click OK after that.


  6. Click Edit... on variable Path
  7. Add the path to Composer directory and click OK
  8. Open cmd and check if it's correctly set up with command composer --version
     

Once you have Composer installed, you can now install Laravel! Wew, finally! To do it, simply enter command composer global require laravel/installer. After it has successfully install, confirm it by entering command laravel --version. If you encounter an error like "'laravel' is not recognized as an internal or external command, operable program or batch file.", add new variable path to Composer/vendor/bin (where there's laravel.bat). After that, restart cmd and confirm version again. The error should be gone now.



That is all for now! All the required things have been installed and we finally can get into the exciting part which is the Laravel itself! But please expect there may be more to install later. Hahaha.. who knows? In the next post, I'm going to write what I've learned from watching freeCodeCamp full course of Laravel. If you by any chance has more experience with Laravel, and feel like there's some things wrong in this post, you're free to correct me. 


No comments:

Post a Comment