How to run a symfony project in localhost?

by darrion.kuhn , in category: PHP Frameworks , 9 months ago

How to run a symfony project in localhost?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by giovanny.lueilwitz , 9 months ago

@darrion.kuhn 

To run a Symfony project on localhost, follow these steps:

  1. Install Symfony's dependencies and tools: Install PHP and Composer (dependency manager for PHP) Run composer install to install the dependencies listed in the project's composer.json file.
  2. Configure the Database: Open the .env file and set the database connection parameters (e.g., database name, username, and password).
  3. Create the Database: Run php bin/console doctrine:database:create to create the configured database.
  4. Create Database Schema: Run php bin/console doctrine:schema:create to create the required database tables.
  5. Start the Local Server: Run symfony serve to start the local web server, or use php -S localhost:8000 -t public if you don't have the Symfony CLI installed.
  6. Access the Application: Open your web browser and navigate to http://localhost:8000 (or the specified port) to access your Symfony application.
  7. Optional: Clear the Cache: If you make changes to the templates or configurations, run php bin/console cache:clear to clear the application cache.


Remember to keep your dependencies updated and refer to the Symfony documentation for specific commands and additional configurations for your project.