๐๐ฒ๐ฝ๐น๐ผ๐๐ถ๐ป๐ด ๐ฆ๐๐บ๐ณ๐ผ๐ป๐ ๐ด ๐๐ผ ๐ฐ๐ฃ๐ฎ๐ป๐ฒ๐น
Many guides assume you have SSH access. Shared hosting often lacks it. You need a different way to deploy.
Here is your step by step guide.
Check your assets first. Use asset('images/') instead of asset('/images/'). This stops loading errors in production.
Set up environment variables. Register DotenvDumpCommand in services.yaml. Run the dotenv:dump command. This creates .env.local.php. It makes your app faster.
Prepare your vendors and cache.
- Run composer install --no-dev --optimize-autoloader.
- Run cache:clear with APP_ENV=prod.
Fix Apache routing.
- Install symfony/apache-pack.
- This creates the .htaccess file.
Update your folder structure.
- Change the public-dir in composer.json to public_html.
- cPanel uses this folder for public files.
Build your assets.
- Run tailwind:build.
- Run asset-map:compile.
Update Kernel.php.
- Add the getProjectDir method.
- This tells Symfony where the root directory is.
Upload your files. Zip these items:
- bin/
- config/
- migrations/
- public_html/
- src/
- templates/
- vendor/
- var/
- .env.local.php
Do not upload these:
- .git/
- node_modules/
- tests/
- var/cache/
Upload the zip to cPanel. Your app is live.
Source: https://dev.to/ashrafchitambaa/deploying-symfony-8-to-cpanel-step-by-step-guide-4k5o