Skip to content

KwanJunEr/laravel_learn_tutorial

Repository files navigation

composer create-project laravel/laravel your-app

using Composer only gives you a clean Laravel backend, and you can connect with other frontend framework separately: It setting up Laravel purely as a backend — meaning:

  • It runs PHP and serves APIs (routes like /api/...).
  • It uses MySQL, Eloquent models, controllers, etc.
  • It can serve JSON data to any frontend.
But can add in other stuff later


Notes Section1

Development Environment

Laragon

Can go to MySQL to open HeidiSQL

Blade Directives

Documentation Link: https://laravel.com/docs/11.x/blade#blade-directives

Laragon Apache Cannot Run issue with different php version

Have to refer to Thread-safe php version


resources/ vs public/

resources/ folder
  • Contains raw, uncompiled assets:
    • CSS (e.g., SCSS/SASS)
    • JavaScript (e.g., ES6, Vue/React components)
    • Images you might process
  • These files are not directly accesible via URL
  • They need to be compiled or copied to the public/folder before the brower can load them
public/ folder
  • The only folder accessible directly by the browser.
  • Any file you want to load with , <script>, or must be in public/.
  • The URL for the browser corresponds to the path in public/:

2️⃣ How assets flow in Laravel

1)You write raw assets in resources/ (e.g., resources/css/app.css). 2)You run Laravel Mix / Vite to compile assets:

npm run dev # development npm run build # production

3)Compiled assets are output to public/ (default public/css, public/js). 4)The browser accesses only the files in public/.

3️⃣ Why not serve directly from resources/

1)resources/ is not web-accessible for security reasons. 2) If you expose resources/ to the web, users could see your uncompiled source code, config files, or even secrets accidentally. 3) Laravel is designed so that only public/ is the document root. 4) Think of resources/ as your “workspace” and public/ as your “live website folder” that the web server can serve.


Route Linking

Blade Link Without Named Route

The browser will go to the root URL (/)

Works exactly the same as using a named route, just less flexible if the URL changes later

Named Routes

  
    Route::get('/', function () {
    return view('customer.index');
})->name('home');
  

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published