Cara menggunakan php-fpm environment variables
Show
Symfony Local Web ServerYou can run Symfony applications with any web server (Apache, nginx, the internal PHP web server, etc.). However, Symfony provides its own web server to make you more productive while developing your applications. Although this server is not intended for production use, it supports HTTP/2, TLS/SSL, automatic generation of security certificates, local domains, and many other features that sooner or later you'll need when developing web projects. Moreover, the server is not tied to Symfony and you can also use it with any PHP application and even with HTML or single page applications. InstallationThe Symfony server is part of the Getting StartedThe Symfony server is started once per project, so you may end up with several instances (each of them listening to a different port). This is the common workflow to serve a Symfony project: Running the server this way makes it display the log messages in the console, so you won't be able to run other commands at the same time. If you prefer, you can run the Symfony server in the background: Enabling PHP-FPMNote PHP-FPM must be installed locally for the Symfony server to utilize. When the server starts, it checks for Tip When an Enabling TLSBrowsing the secure version of your applications locally is important to detect problems with mixed content early, and to run libraries that only run in HTTPS. Traditionally this has been painful and complicated to set up, but the Symfony server automates everything. First, run this command: This command creates a local certificate authority, registers it in your system trust store, registers it in Firefox (this is required only for that browser) and creates a default certificate for Before browsing your local application with HTTPS instead of HTTP, restart its server stopping and starting it again. Different PHP Settings Per ProjectSelecting a Different PHP VersionIf you have multiple PHP versions installed on your computer, you can tell Symfony which one to use creating a file called Tip The Symfony server traverses the directory structure up to the root directory, so you can create a Run the command below if you don't remember all the PHP versions installed on your computer: Overriding PHP Config Options Per ProjectYou can change the value of any PHP runtime config option per project by creating a file called Running Commands with Different PHP VersionsWhen running different PHP versions, it is useful to use the main Local Domain NamesBy default, projects are accessible at some random port of the
Setting up the Local ProxyLocal domains are possible thanks to a local proxy provided by the Symfony server. If this is the first time you run the proxy, you must configure it as follows:
Now run this command to start the proxy: If the proxy doesn't work as explained in the following sections, check these:
Defining the Local DomainBy default, Symfony proposes If you have installed the local proxy as explained in the previous section, you can now browse Tip Browse the http://127.0.0.1:7080 URL to get the full list of local project directories, their custom domains, and port numbers. When running console commands, add the Note Although env var names are always defined in uppercase, the Tip If you prefer to use a different TLD, edit the Long-Running CommandsLong-running commands, such as the ones that compile front-end web assets, block the terminal and you can't run other commands at the same time. The Symfony server provides a
Docker IntegrationThe local Symfony server provides full Docker integration for projects that use it. To learn more about Docker & Symfony, see Using Docker with Symfony. When the web server detects that Docker Compose is running for the project, it automatically exposes some environment variables. Via the Consider the following configuration: The web server
detects that a service exposing port If the service is not in the supported list below, generic environment variables are set: If the In this
example, the service is named Here is the list of supported services with their ports and default Symfony prefixes:
You can open web management interfaces for the services that expose them: Or click on the links in the "Server" section of the web debug toolbar. Tip To debug and list all exported environment variables, run Tip For some services, the web server also exposes environment variables understood by CLI tools related to the service. For instance, running When Docker services are running, browse a page of your Symfony application and check the "Symfony Server" section in the web debug toolbar; you'll see that "Docker Compose" is "Up". Note If you don't want environment variables to be exposed for a service, set the If your Docker Compose file is not at the root of the project, use the Caution When using the Symfony binary with SymfonyCloud IntegrationThe local Symfony server provides full, but optional, integration with SymfonyCloud, a service optimized to run your Symfony applications on the cloud. It provides features such as creating environments, backups/snapshots, and even access to a copy of the production data from your local machine to help debug any issues. Read SymfonyCloud technical docs. |