Przejdź do głównej zawartości

Up and running with Laravel

Today I'll show you how to start working with Laravel - a modern PHP framework.

After reading this article you'll be able to:
- Install XAMPP
- Configure Virtual Hosts on Apache
- Create your first application in Laravel
- Run the application
- Start coding

As a first step I encourage you to visit Laravel.com to get some background knowledge about Laravel.


Laravel is a PHP framework which is build on top of the MVC pattern (MVC stands for Model View Controller).
You can find general explanation of MVC design pattern with some code examples written in Java here.

I assume that you've already installed XAMPP which has version for Linux, Windows and OS X.
Personally I'm using Windows in this tutorial but on each operating system it should work similarly.
You can get the installer of XAMPP from this page: https://www.apachefriends.org/pl/index.html.
When installer prompts you which options you want to install, you need to select Apache and you are free to skip the rest options as we don't need database and other features for now.


When Apache is up and running, then next step is to configure virtual host so that Apache can understand how to translate domain name to specific folder on your machine. In order to define virtual host open the file C:\xampp\apache\conf\extra\httpd-vhosts.conf, and append the following code to the end of the file:


DocumentRoot "C:\xampp\htdocs\blog\public"
ServerAdmin blog

Options Indexes FollowSymLinks
AllowOverride All
Require all granted




Now we have 2 options - we can buy a domain like mydomain.com and use A record to redirect to our server, or we can simulate similar behavior using hosts file. For development purposes I recommend the latter option, however when your app will go live, you should use domain because then it will be accessible to anyone in the internet. Hosts file ranhe is limitted to only your local machine.
Let's add some code at the end of file: C:\Windows\System32\drivers\etc\hosts
This is the code:
127.0.0.1 blog

This code instructs your local server to use localhost(127.0.0.1) when "blog" is requested in the web browser.

Now let's install laravel.
The prerequisite step is to install Composer. Composer will install Laravel framework and all dependend libraries on your machine. The installer for windows is available here.
When you sucessfully install Composer then you should install Laravel by running the following command from your command line:

composer global require "laravel/installer"

Once laravel is installed you're able to create a new laravel project. Go to C:\xampp\htdocs and run the command:
laravel new blog

When you open the folder in Visual Studio Code, or different code editor you'll see the file structure. Take a moment and look at what's the folder structure and what's inside files.



The final step: Run web browser.

If you made all configuration steps coddectly, you should see a similar screen.
Next step - learn how Laravel works. This is an up-to-date documentation:
https://laravel.com/docs/5.4

Komentarze

Popularne posty z tego bloga

Unleash the power of ChatGPT in your C# applications with NGpt - C# OpenAI GPT client

Meet NGpt - OpenAI GPT C# client library that will make your conversations with ChatGPT a breeze! Have you ever been struggling building your own smart AI application in C#? Well, now you can use ChatGpt inside your application! Introducing NGpt, the powerful .NET library that lets you integrate ChatGPT seamlessly into your C# applications. No more nigts spent on building your own AI solitions, no more convoluted logic and building complex business rules - just pure AI bliss. In this blog post, we'll dive into the wonderful world of NGpt and show you how easy it is to use. You might even find a few laughs along the way. The Magic of NGpt NGpt is a transient fault-tolerant .NET 6 OpenAI client that simplifies ChatGPT integration for C# developers. It's like your friendly neighborhood Spider-Man - always there to help you out when you need it most. With just your OpenAI API key, you can start coding AI applications in C# faster than you can say "Peter Parker." Let&

Specflow czyli BDD w praktyce

Dzisiaj pokażę w praktyce w jaki sposób zbieram wymagania korzystając z narzędzia Specflow. Na początku przypomnę nasze historie użtkownika. Potem skonfigurujemy dodatek Specflow Visual Studio. Na końcu pokażę jak wygląda język Gherkin i zaimplementujemy pierwszą historię użytkownika US1. Oto lista funkcjonalności, które będę implementował w aplikacji Perfect Life: US1: Jako użytkownik aplikacji mobilnej chcę ekran logowania aby mieć możliwość zapisywania swoich postępów US2: Jako użytkownik aplikacji mobilnej chcę mieć kalkulator wskaźnika BMI aby móc mierzyć poziom swojej kondycji US3: Jako użytkownik aplikacji mobilnej chcę widzieć wykresy aby móc wizualnie interpretować swoje postępy US4: Jako użytkownik aplikacji mobilnej chcę mieć możliwość rozwiązania quizu, żeby zbadać wskaźnik Body Age US5: Jako użytkownik aplikacji mobilnej chcę pobierać pliki PDF aby mieć dostęp do planów dietetycznych US6: Jako administrator aplikacji chcę zapisywać dane telemetryczne aby móc an

How to call webAPI service in Xamarin?

In the last few weeks I worked on the web service written in ASP.NET Core. I had a plan to connect the Xamarin application to this web service. Today I'll show you how you can connect your Xamarin app to web service located anywhere in the cloud. First we need to have a web service deployed, which is our server-side part of the system. I describe how to create a web service in ASP.NET COre in my previous post: . Today I'll demonstrate how it works from client perspective, in our case it's Xamarin.Forms application but web application or desktop application can use exactly the same code. This is the great benefit of using C# language - we can use the same code on multiple platforms. OK, I bet you're interested in the code. Let's jump to the code. This is the final version of the client class that I can use to save and retrieve data from web service: The class design is straightforward. It has 2 public methods which encapsulate 2 functionalities: adding s