Virajsinh

Laravel Project Setup Latest 2025.md

Nov 7th, 2025 (edited)
174
0
Never
12
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | Source Code | 0 0
  1. # 🚀 Laravel Fresh Project Setup Guide
  2.  
  3. ## 🌟 Magic Setup Commands with Composer
  4.  
  5. You can use Composer scripts to create single commands that fully set up and manage your project.
  6.  
  7. ### Composer Scripts Example (`composer.json`)
  8.  
  9. ```json
  10. {
  11. "scripts": {
  12. "setup": [
  13. "composer install",
  14. "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
  15. "@php artisan key:generate",
  16. "@php artisan migrate --force",
  17. "npm install",
  18. "npm run build",
  19. "composer run clear-all"
  20. ],
  21. "clear-all": [
  22. "@php artisan optimize:clear",
  23. "@php artisan cache:clear",
  24. "@php artisan config:clear",
  25. "@php artisan route:clear",
  26. "@php artisan view:clear"
  27. ],
  28. "db-reset": [
  29. "@php artisan migrate:fresh --seed"
  30. ]
  31. }
  32. }
  33. ```
  34.  
  35. ### How to Use
  36.  
  37. Use the following commands in your terminal:
  38.  
  39. | Command | Description |
  40. | :--- | :--- |
  41. | `composer run setup` | **Sets up the project from scratch** (install deps, generate key, migrate, build assets). |
  42. | `composer run clear-all` | Clears all cache, config, routes, and views. |
  43. | `composer run db-reset` | Resets the database (`migrate:fresh`) and runs seeders. |
  44.  
  45. -----
  46.  
  47. ## ⚙️ Manual Setup Steps
  48.  
  49. If you prefer to set up your project step-by-step:
  50.  
  51. ### 1️⃣ Copy `.env` File
  52.  
  53. Copy the example environment file to create your active configuration file.
  54.  
  55. * **Linux / Mac:**
  56. ```bash
  57. cp .env.example .env
  58. ```
  59. * **Windows:**
  60. ```bash
  61. copy .env.example .env
  62. ```
  63.  
  64. ### 2️⃣ Configure Database in `.env`
  65.  
  66. Update your database credentials in the newly created `.env` file.
  67.  
  68. ```env
  69. DB_CONNECTION=mysql
  70. DB_HOST=127.0.0.1
  71. DB_PORT=3306
  72. DB_DATABASE=laravel
  73. DB_USERNAME=root
  74. DB_PASSWORD=
  75. ```
  76.  
  77. ### 3️⃣ Install Dependencies
  78.  
  79. Install the required PHP and JavaScript packages.
  80.  
  81. ```bash
  82. composer install
  83. npm install
  84. ```
  85.  
  86. ### 4️⃣ Generate Application Key
  87.  
  88. This key is used for session encryption and other security features.
  89.  
  90. ```bash
  91. php artisan key:generate
  92. ```
  93.  
  94. ### 5️⃣ Run Database Migrations
  95.  
  96. Create your database tables based on your migration files.
  97.  
  98. ```bash
  99. php artisan migrate
  100. ```
  101.  
  102. ### 6️⃣ Add Custom Upload Disk Path (Optional)
  103.  
  104. Edit `config/filesystems.php` to define a custom disk for uploads.
  105.  
  106. ```php
  107. // config/filesystems.php
  108.  
  109. 'disks' => [
  110. // ... other disks
  111.  
  112. 'uploads' => [
  113. 'driver' => 'local',
  114. 'root' => public_path('uploads'), // Files stored under public/uploads
  115. 'url' => env('APP_URL') . '/uploads',
  116. 'visibility' => 'public',
  117. ],
  118. ],
  119. ```
  120.  
  121. **Usage Example:**
  122.  
  123. ```php
  124. Storage::disk('uploads')->putFileAs(
  125. "employees/documents/{$employee->id}",
  126. $file,
  127. $filename
  128. );
  129. ```
  130.  
  131. > **Note:** This configuration makes files publicly accessible via the path `public/uploads/...`.
  132.  
  133. ### 7️⃣ Create Auto-loaded Helper Functions (Optional)
  134.  
  135. Helper functions can be used globally in your project without needing explicit imports.
  136.  
  137. 1. **Create the file:** `app/Functions/Helper.php`
  138.  
  139. ```php
  140. <?php
  141.  
  142. if (!function_exists('greet')) {
  143. function greet($name) {
  144. return "Hello, " . $name . "!";
  145. }
  146. }
  147. ```
  148.  
  149. 2. **Update `composer.json` autoload section:** Add the file path to the `"files"` array.
  150.  
  151. ```json
  152. // composer.json
  153.  
  154. "autoload": {
  155. "psr-4": {
  156. "App\\": "app/",
  157. "Database\\Factories\\": "database/factories/",
  158. "Database\\Seeders\\": "database/seeders/"
  159. },
  160. "files": [
  161. "app/Functions/Helper.php"
  162. ]
  163. }
  164. ```
  165.  
  166. 3. **Regenerate Composer autoload:**
  167.  
  168. ```bash
  169. composer dump-autoload
  170. ```
  171.  
  172. Now, the `greet()` function (and any other helpers you add) can be used anywhere in your Laravel project.
  173.  
  174. -----
  175.  
  176. ## ✅ Summary and Best Practices
  177.  
  178. * For full automation, use the Composer script: **`composer run setup`**.
  179. * **Keep uploads public only if necessary.** For sensitive files, store them in a private disk storage configuration.
  180. * Helper functions can be autoloaded globally by defining them in `composer.json` under the `"files"` key and running `composer dump-autoload`.
  181. * Remember to clear your cache often during development with **`composer run clear-all`**.
  182. * Database reset is safely performed via **`composer run db-reset`**.
  183.  
  184. Would you like to search for a specific Laravel package to add to this setup, such as for authentication or debugging?
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Idlalnu
    35 days
    Comment was deleted
  • User was banned
  • Cylunoz
    11 days
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=ruyawypdrw
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment