Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XAMPP installation guide for Windows #428

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 58 additions & 0 deletions _SETUP_DEV_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,64 @@ There are several ways to set up your development server and environment. Basica

Note: to regenerate the docker configuration, use `php artisan sail:install --devcontainer`

### Windows (natively)
On Windows, probably the optimal option with respect to performance is
to simply install a web server and a database server natively on the system,
Copy link
Contributor

@kdmnk kdmnk Feb 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not natively, it's based on Xampp, which is a developer tool and also does a lot of "magic" in the background. We had issues with Xampp before, which did not support the newest PHP versions. Apparently, I see that currently this is not the case, however, we should make a note here to check it before even trying to set up.

instead of using containers or virtual machines.
However, the installation itself is a bit more complicated.
(But actually, there aren't as many mysterious errors as with containers.)

1. Download and install the following programs:
- [XAMPP](https://www.apachefriends.org/download.html) (the newest available one) – this includes the PHP interpreter, the Apache web server and the MySQL database server.
- Besides the obligatory options, we only need MySQL, phpmyadmin and Fake Sendmail.
- You don't need to allow it through the firewall, as we are only going to access these locally.
- [Composer](https://getcomposer.org/download/) – this is a package manager for PHP.
- It's enough to install it only for your account when asked.
- [NVM](https://github.com/coreybutler/nvm-windows/releases) (choose `nvm-setup.exe`) – this downloads Node.js and the NPM package manager, which will again download other things:D
- [Git](https://gitforwindows.org/) – the version manager.
- For the text editor, the simplest is to choose Windows' Notepad (or VS Code, if you have it). Otherwise, you can stick to the defaults.
2. Open `C:\xampp\php\php.ini`. This is PHP's configuration file. We need to enable two extensions here for things to work.
- To do this, search for the lines `;extension=zip` and `;extension=gd`, and delete the semicolon (`;`) before them. (If there are more than one copies of them, it's enough to enable only one instance.)
3. Open a command prompt (open Start menu and type `cmd`).
4. Type `nvm install lts`. This command will install NPM for you.
5. To be able to use it, you need to add the folder containing the NPM binary to the operating system's PATH variable (so that the command prompt will find it).
- Check the installed version of Node.js with `nvm list`
- Follow [these steps](https://www.mathworks.com/matlabcentral/answers/94933-how-do-i-edit-my-system-path-in-windows). Add the path `%USERPROFILE%\AppData\Roaming\nvm\vXX.XX.X`, where `XX.XX.X` is the version printed by `nvm list`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid links to random pages which might not be available/updated later. Just mention adding it to the path, everyone can google it.

6. Close the command prompt and open it again. This way, it is going to see the binaries under the folder added.
7. Select the directory under which you want to install the project, and `cd` to that directory. For example, if you choose `C:\Users\myname\Documents\`, say `cd C:\Users\myname\Documents\`.
8. Download the project by saying `git clone https://github.com/EotvosCollegium/mars`. This will create a `mars` folder under the current directory.
9. Say `cd mars`.
10. There are lots of dependencies Laravel (and specifically Mars) use. But now, Composer and NPM does this work instead of you. Just say:
```bat
composer update
composer install
npm install
npm run dev
```
11. Make a copy of the file named `.env.example` and call it `.env`. This is the configuration file of Mars; this specifies some settings that are local to the environment (in this case, your machine).
12. Open `.env`. Change `DB_HOST` to `127.0.0.1` (this is the IP on which you can access your own machine) and `DB_PASSWORD` to some long, random string (you won't have to remember it).
13. There are still some adventures left: we need to start and configure the database server. For this:
- Open the XAMPP Control Panel.
- Here, start MySQL.
- Then, click on the `Admin` button next to the `Start`˛button. This will open an administration page called _phpmyadmin_.
- On the left side, create a new database and name it `mars`.
- Select `User accounts` and add a new user. This is what Mars is going to use. Name it `mars` and give it the password you wrote in `.env`.
- After you created it, click `Edit privileges` and switch to the `Database` tab. Click on the `mars` database you created in the first step, and then `Go`. `Check all` and `Go` again.
- You can now close this page.
14. To initialise the database (with fancy test data!) and some other things, switch back to the command prompt and while being in the `mars` folder, run:
```bat
php artisan key:generate
php artisan migrate:fresh --seed
```
15. Finally, you can start your server! For this, type `php artisan serve`. (To stop the server, press Control-C. If you want to use the command prompt, you will need to open a new window.)
16. Your local site can be accessed from the browser at `127.0.0.1:8000`. Log in with `example@eotvos.elte.hu` and `asdasdasd`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The credentials are coming from .env just reference that.

17. If there are firewall exceptions for Apache or mysqld under _Control Panel\System and Security\Windows Defender Firewall\Allowed apps_, you can safely delete them, as you only need them on your own machine.

Most of these things need to be done only once. There are two steps you have to take every time you start working:
- Start MySQL in XAMPP Control Panel. (If it asks, you need not let it through the firewall.)
- Open a command prompt, `cd` to the `mars` directory and run `php artisan serve`.
When you are done, simply shut down your server by pressing Control-C while in the command prompt.

### OS X
For OS X, [Valet](https://laravel.com/docs/6.x/valet) gives a pretty smooth experience. Easy to download, easy to configure.

Expand Down