Laravel Course

Like all popular PHP frameworks such as Symfony, Yii, Codeigniter and others, Laravel is a MVC framework (Model-View-Controller). It is an application architecture model which separates an application into three logical components:

Basic directories structure

Here is an image with directories structure of Laravel 5.5:
laravel directories structure

The app folder in the Laravel contains the Models and Controllers of the application.
Models are created in the root of the app folder, where as Controllers and Middlewares are created in their respective folders inside the Http folder.
Views in Laravel (the templates that are rendered as HTML) are created in views folder inside the resources folder.

The resources directory contains raw assets such as the LESS and Sass files, localization and language files, and Templates that are rendered as HTML.
The storage directory contains App storage, like file uploads etc. Framework storage (cache), and application-generated logs.
The vendor directory contains composer dependencies.

Routing for controllers is handled by the Web.php file located inside the routes folder.
The vendor directory contains composer dependencies.
In the .env file you can add your data for connecting to a mysql database (DB_DATABASE, DB_USERNAME, DB_PASSWORD).
You can also configure the locale, time zone, etc. of the application in the config/app.php file.
The public folder is the application’s document root. It starts the Laravel application. It also contains the assets of the application like JavaScript, CSS, Images, etc.

- To run your app, you need to go to the public folder of your Laravel application.

Display desired content

Once we know the Laravel architecture and the directory and files structure, we can edit and create files to display in browser the content we want.
Open the Command Line Interface (CMD on Windows), navigate to the folder where you have Laravel project, and run this command to start the php built-in server:
php artisan serve
If you access this URL in browser:
http://localhost:8000/
- it shows the predefined Home page. To change that page, open the "welcome.blade.php" file (in the "resources/views/" folder), and edit its content with any php, html, css, javascript code you want.
- For example, put this code in welcome.blade.php file:
<!doctype html>
<html lang="{{app()->getLocale()}}">
<head>
<meta charset="utf-8">
<title>Hello</title>
</head>
<body>
<h1>Hello to Me</h1>
<p>Laravel {{App::VERSION()}}</p>
</body>
</html>
Now, if you access again the "//localhost:8000/" in browser, you'll see a page like in this image:

php artisan serve

The ".blade" in the name of the "welcome.blade.php" file it is for parsing Blade Templates.
If you rename that file just "welcome.php", it will display its content, but without parsing the Blade Templates.
- See this page for more details about Laravel - Blade Templates

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag is used to add lists into <ul> and <ol> elements?
<dt> <dd> <li>
<ul>
 <li>http://coursesweb.net/html/</li>
 <li>http://coursesweb.net/css/</li>
</ul>
Which value of the "display" property creates a block box for the content and ads a bullet marker?
block list-item inline-block
.some_class {
  display: list-item;
}
Which instruction converts a JavaScript object into a JSON string.
JSON.parse() JSON.stringify eval()
var obj = {
 "courses": ["php", "javascript", "ajax"]
};
var jsonstr = JSON.stringify(obj);
alert(jsonstr);    // {"courses":["php","javascript","ajax"]}
Indicate the PHP class used to work with HTML and XML content in PHP.
stdClass PDO DOMDocument
$strhtml = '<body><div id="dv1">CoursesWeb.net</div></body>';
$dochtml = new DOMDocument();
$dochtml->loadHTML($strhtml);
$elm = $dochtml->getElementById("dv1");
echo $elm->nodeValue;    // CoursesWeb.net
Laravel Basic Architecture

Last accessed pages

  1. PHP PDO - prepare and execute (9187)
  2. jQuery Ajax - load() method (10835)
  3. Creating XML data - E4X in ActionScript 3 (3088)
  4. Introduction to ActionScript 3 (3380)
  5. Accesing XML data - E4X (1436)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (468)
  2. CSS cursor property - Custom Cursors (78)
  3. The Mastery of Love (69)
  4. PHP-MySQL free course, online tutorials PHP MySQL code (62)
  5. CSS3 2D transforms (46)