Advertisement
Virajsinh

Laravel New Project Structure Create.bat

Sep 28th, 2024 (edited)
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 5.97 KB | Source Code | 0 0
  1. @echo off
  2.  
  3. echo Created by VeeRa (*_#)
  4. echo.
  5.  
  6. mkdir resources\views\auth
  7. mkdir resources\views\backend
  8. mkdir resources\views\emails\backend
  9. mkdir resources\views\emails\frontend
  10. mkdir resources\views\pdf
  11. mkdir resources\views\layouts
  12. mkdir resources\views\partials\backend
  13. mkdir public\uploads
  14. mkdir public\css
  15. mkdir public\js
  16. mkdir public\plugins
  17. mkdir public\images
  18. mkdir app\Import
  19. mkdir app\Export
  20. mkdir app\Mail
  21. mkdir app\Http\Requests
  22. mkdir app\Http\Controllers\API
  23. mkdir app\Http\Controllers\Auth
  24. mkdir app\Http\Controllers\Backend
  25. mkdir app\Http\Middleware
  26.  
  27. REM Define the path for helpers
  28. set "filePath=app\Helpers.php"
  29.  
  30. REM Check if the helpers file already exists
  31. if not exist "%filePath%" (
  32.     echo ^<?php > "%filePath%"
  33.     echo // Helper functions can be added here >> "%filePath%"
  34.     echo File created: %filePath%
  35. ) else (
  36.     echo File already exists: %filePath%
  37. )
  38.  
  39. REM Define the path for Kernel.php
  40. set "kernelPath=app\Http\Kernel.php"
  41.  
  42. REM Check if the Kernel.php file already exists
  43. if not exist "%kernelPath%" (
  44.     echo ^<?php > "%kernelPath%"
  45.     echo namespace App\Http; >> "%kernelPath%"
  46.     echo. >> "%kernelPath%"
  47.     echo use Illuminate\Foundation\Http\Kernel as HttpKernel; >> "%kernelPath%"
  48.     echo. >> "%kernelPath%"
  49.     echo class Kernel extends HttpKernel >> "%kernelPath%"
  50.     echo { >> "%kernelPath%"
  51.     echo     // Add Code Here >> "%kernelPath%"
  52.     echo } >> "%kernelPath%"
  53.     echo Kernel.php file created: %kernelPath%
  54. ) else (
  55.     echo Kernel.php file already exists: %kernelPath%
  56. )
  57.  
  58. REM Check if .env.example file exists before copying
  59. if exist ".env.example" (
  60.    REM Check if .env file already exists
  61.     if exist ".env" (
  62.         set /p overwriteEnv="The .env file already exists. Do you want to overwrite it? (yes/no): "
  63.         if /i "%overwriteEnv%"=="yes" (
  64.             copy .env.example .env
  65.             echo .env file has been overwritten with .env.example.
  66.  
  67.             REM Uncomment DB related lines in .env using PowerShell
  68.             powershell -Command "(Get-Content .env) -replace '^# DB_HOST=', 'DB_HOST=' | Set-Content .env"
  69.             powershell -Command "(Get-Content .env) -replace '^# DB_PORT=', 'DB_PORT=' | Set-Content .env"
  70.             powershell -Command "(Get-Content .env) -replace '^# DB_DATABASE=', 'DB_DATABASE=' | Set-Content .env"
  71.             powershell -Command "(Get-Content .env) -replace '^# DB_USERNAME=', 'DB_USERNAME=' | Set-Content .env"
  72.             powershell -Command "(Get-Content .env) -replace '^# DB_PASSWORD=', 'DB_PASSWORD=' | Set-Content .env"
  73.            
  74.             REM Update DB_CONNECTION in .env file using PowerShell
  75.             powershell -Command "(Get-Content .env) -replace '^DB_CONNECTION=.*', 'DB_CONNECTION=mysql' | Set-Content .env"
  76.            
  77.             REM Prompt user for DB_DATABASE name
  78.             set /p dbname="Enter the DB_DATABASE name: "
  79.            
  80.             REM Update DB_DATABASE in .env file using PowerShell
  81.             powershell -Command "(Get-Content .env) -replace '^DB_DATABASE=.*', 'DB_DATABASE=%dbname%' | Set-Content .env"
  82.            
  83.             echo DB_DATABASE has been updated to %dbname%
  84.         ) else (
  85.             echo .env file will not be overwritten.
  86.         )
  87.     ) else (
  88.         copy .env.example .env
  89.         echo .env.example file copied to .env
  90.        
  91.         REM Uncomment DB related lines in .env using PowerShell
  92.         powershell -Command "(Get-Content .env) -replace '^# DB_HOST=', 'DB_HOST=' | Set-Content .env"
  93.         powershell -Command "(Get-Content .env) -replace '^# DB_PORT=', 'DB_PORT=' | Set-Content .env"
  94.         powershell -Command "(Get-Content .env) -replace '^# DB_DATABASE=', 'DB_DATABASE=' | Set-Content .env"
  95.         powershell -Command "(Get-Content .env) -replace '^# DB_USERNAME=', 'DB_USERNAME=' | Set-Content .env"
  96.         powershell -Command "(Get-Content .env) -replace '^# DB_PASSWORD=', 'DB_PASSWORD=' | Set-Content .env"
  97.        
  98.         REM Update DB_CONNECTION in .env file using PowerShell
  99.         powershell -Command "(Get-Content .env) -replace '^DB_CONNECTION=.*', 'DB_CONNECTION=mysql' | Set-Content .env"
  100.        
  101.         REM Prompt user for DB_DATABASE name
  102.         set /p dbname="Enter the DB_DATABASE name: "
  103.        
  104.         REM Update DB_DATABASE in .env file using PowerShell
  105.         powershell -Command "(Get-Content .env) -replace '^DB_DATABASE=.*', 'DB_DATABASE=%dbname%' | Set-Content .env"
  106.        
  107.         echo DB_DATABASE has been updated to %dbname%
  108.     )
  109. ) else (
  110.     echo .env.example file does not exist.
  111. )
  112.  
  113. REM Create multiple files in the Auth controller directory
  114. set "authDir=app\Http\Controllers\Auth"
  115.  
  116. set "controllerFiles=ConfirmPasswordController.php ForgotPasswordController.php LoginController.php RegisterController.php ResetPasswordController.php VerificationController.php"
  117.  
  118. for %%f in (%controllerFiles%) do (
  119.     if not exist "%authDir%\%%f" (
  120.         echo ^<?php > "%authDir%\%%f"
  121.         echo // %%f file created >> "%authDir%\%%f"
  122.         echo File created: %authDir%\%%f
  123.     ) else (
  124.         echo File already exists: %authDir%\%%f
  125.     )
  126. )
  127.  
  128. REM Create Blade view files in the auth directory
  129. set "viewDir=resources\views\auth"
  130.  
  131. set "bladeFiles=confirm.blade.php email.blade.php reset.blade.php login.blade.php register.blade.php verify.blade.php"
  132.  
  133. for %%b in (%bladeFiles%) do (
  134.     if not exist "%viewDir%\%%b" (
  135.         type nul > "%viewDir%\%%b"
  136.         echo File created: %viewDir%\%%b
  137.     ) else (
  138.         echo File already exists: %viewDir%\%%b
  139.     )
  140. )
  141.  
  142. if exist "composer.json" (
  143.     composer install
  144.     php artisan key:generate
  145.     php artisan migrate
  146.     php artisan optimize:clear
  147.     php artisan cache:clear
  148.     php artisan config:cache
  149.     php artisan config:clear
  150.     php artisan view:cache
  151.     php artisan view:clear
  152.     php artisan route:clear
  153.     php artisan install:api
  154.     php artisan route:list
  155. ) else (
  156.     echo composer.json file does not exist.
  157. )
  158.  
  159. echo Folders and Files Created Successfully.
  160. pause
  161.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement