Advertisement
Virajsinh

Laravel Project Setup Steps By VeeRa README.md

Sep 13th, 2024 (edited)
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. # Laravel Project Setup By VeeRa
  2.  
  3. 1. Download Laravel Either Make Via Command Line
  4.  
  5. [Download Laravel](https://github.com/laravel/laravel/tags)
  6.  
  7. Command ```composer create-project --prefer-dist laravel/laravel my-laravel-app```
  8.  
  9. ```composer create-project``` : Tells Composer to create a new project.
  10.  
  11. ```--prefer-dist``` : Uses distribution archives (ZIP files) for faster installation.
  12.  
  13. ```laravel/laravel``` : Specifies the Laravel starter project package.
  14.  
  15. ```my-laravel-app``` : The name of the directory to create for your new Laravel project.
  16.  
  17. 2. Open Project Folder And Open Currect Directory Command Terminal
  18.  
  19. ```base
  20. cp .env.example .env
  21. ```
  22. Type Above Command For Copy .env File From .env.example
  23.  
  24. 3. Add Two Files in Main Project Directory `index.php` And `.htaccess`
  25.  
  26. File Name : ```index.php```
  27.  
  28. ```php
  29. <?php
  30.  
  31. /**
  32. * Laravel - A PHP Framework For Web Artisans
  33. *
  34. * @package Laravel
  35. * @author Taylor Otwell <taylor@laravel.com>
  36. */
  37.  
  38. $uri = urldecode(
  39. parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
  40. );
  41.  
  42. // This file allows us to emulate Apache's "mod_rewrite" functionality from the
  43. // built-in PHP web server. This provides a convenient way to test a Laravel
  44. // application without having installed a "real" web server software here.
  45. if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
  46. return false;
  47. }
  48.  
  49. require_once __DIR__.'/public/index.php';
  50. ```
  51.  
  52. File Name : ```.htaccess```
  53.  
  54. ```
  55. <IfModule mod_rewrite.c>
  56. RewriteEngine On
  57.  
  58. RewriteCond %{REQUEST_FILENAME} -d [OR]
  59. RewriteCond %{REQUEST_FILENAME} -f
  60. RewriteRule ^ ^$1 [N]
  61.  
  62. RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
  63. RewriteRule ^(.*)$ public/$1
  64.  
  65. RewriteCond %{REQUEST_FILENAME} !-d
  66. RewriteCond %{REQUEST_FILENAME} !-f
  67. RewriteRule ^ index.php
  68.  
  69. # Handle Authorization Header
  70. RewriteCond %{HTTP:Authorization} .
  71. RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  72. </IfModule>
  73. ```
  74. 4. Add ```.htaccess``` in ```public``` Folder
  75.  
  76. File Name : ```.htaccess```
  77.  
  78. ```
  79. <IfModule mod_rewrite.c>
  80. <IfModule mod_negotiation.c>
  81. Options -MultiViews -Indexes
  82. </IfModule>
  83.  
  84. RewriteEngine On
  85.  
  86. # Handle Authorization Header
  87. RewriteCond %{HTTP:Authorization} .
  88. RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  89.  
  90. # Redirect Trailing Slashes If Not A Folder...
  91. RewriteCond %{REQUEST_FILENAME} !-d
  92. RewriteCond %{REQUEST_URI} (.+)/$
  93. RewriteRule ^ %1 [L,R=301]
  94.  
  95. # Send Requests To Front Controller...
  96. RewriteCond %{REQUEST_FILENAME} !-d
  97. RewriteCond %{REQUEST_FILENAME} !-f
  98. RewriteRule ^ index.php [L]
  99. </IfModule>
  100. ```
  101.  
  102. 5. Install Composer Packages in Project Directory :
  103. ```bash
  104. composer install
  105. ```
  106.  
  107. 6. Generate Laravel Application Key :
  108. ```bash
  109. php artisan key:generate
  110. ```
  111.  
  112. 7. Clear Project Cache :
  113. ```bash
  114. php artisan migrate
  115. ```
  116.  
  117. 8. Clear Project Cache :
  118. ```bash
  119. php artisan optimize:clear
  120. ```
  121.  
  122. ```bash
  123. php artisan cache:clear
  124. ```
  125.  
  126. ```bash
  127. php artisan config:cache
  128. ```
  129.  
  130. ```bash
  131. php artisan config:clear
  132. ```
  133.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement