Macos Docker For Php Development Tutorial

 
Macos Docker For Php Development Tutorial Average ratng: 7,8/10 3119 reviews

Docker Desktop. The preferred choice for millions of developers that are building containerized apps. Docker Desktop is a tool for MacOS and Windows machines for the building and sharing of containerized applications and microservices. Access Docker Desktop and follow the guided onboarding to build your first containerized application in minutes.

  1. Docker For Php Developers
  2. Docker Tutorial Pdf
  3. Macos Docker For Php Development Tutorial For Beginners
  4. Macos Docker For Php Development Tutorial Pdf
  • Apr 27, 2018  Docker is a powerful platform for building, managing, and running containerized applications. In this tutorial, you'll learn how you can use Docker to package and distribute your applications. We'll show you how to install the tools, download and run an off-the-shelf image, and then build images of our own.
  • Jun 01, 2015  Our docker-compose.yml file defines an Nginx Docker container identical to the Docker container we ran earlier: it instantiates the tutorial/nginx image, it maps host port 8080 to container port 80, and it mounts the /src directory and /src/vhost.conf file to the container's filesystem. This time, however, we define the Nginx Docker container.
Estimated reading time: 17 minutes

Welcome to Docker Desktop!

The Docker Desktop for Mac section contains information about the Docker Desktop Community Stable release. For information about features available in Edge releases, see the Edge release notes. For information about Docker Desktop Enterprise (DDE) releases, see Docker Desktop Enterprise.

Docker is a full development platform to build, run, and share containerized applications. Docker Desktop is the best way to get started with Docker on Mac.

See Install Docker Desktop for download information, system requirements, and installation instructions.

Check versions

Ensure your versions of docker and docker-compose areup-to-date and compatible with Docker.app. Your output may differ if you arerunning different versions.

Explore the application

  1. Open a command-line terminal and test that your installation works byrunning the simple Docker image,hello-world:

  2. Start a Dockerized web server. Like the hello-world image above, if theimage is not found locally, Docker pulls it from Docker Hub.

  3. In a web browser, go to http://localhost/ to view the nginx homepage.Because we specified the default HTTP port, it isn’t necessary to append:80 at the end of the URL.

    Early beta releases used docker as the hostname to build the URL. Now,ports are exposed on the private IP addresses of the VM and forwarded tolocalhost with no other host name set.

  4. View the details on the container while your web server is running (withdocker container ls or docker ps):

  5. Stop and remove containers and images with the following commands. Use the“all” flag (--all or -a) to view stopped containers.

Preferences

Choose the Docker menu > Preferences from themenu bar and configure the runtime options described below.

General

On the General tab, you can configure when to start and update Docker:

  • Start Docker Desktop when you log in: Automatically starts Docker Desktop when you open your session.

  • Automatically check for updates: By default, Docker Desktop automatically checks for updates and notifies you when an update is available. You can manually check for updates anytime by choosing Check for Updates from the main Docker menu.

  • Include VM in Time Machine backups: Select this option to back up the Docker Desktop virtual machine. This option is disabled by default.

  • Securely store Docker logins in macOS keychain: Docker Desktop stores your Docker login credentials in macOS keychain by default.

  • Send usage statistics: Docker Desktop sends diagnostics, crash reports, and usage data. This information helps Docker improve and troubleshoot the application. Clear the check box to opt out.

    Click Switch to the Edge version to learn more about Docker Desktop Edge releases.

Resources

The Resources tab allows you to configure CPU, memory, disk, proxies, network, and other resources.

Advanced

On the Advanced tab, you can limit resources available to Docker.

Advanced settings are:

CPUs: By default, Docker Desktop is set to use half the number of processorsavailable on the host machine. To increase processing power, set this to ahigher number; to decrease, lower the number.

Docker For Php Developers

Memory: By default, Docker Desktop is set to use 2 GB runtime memory,allocated from the total available memory on your Mac. To increase the RAM, set this to a higher number. To decrease it, lower the number.

Swap: Configure swap file size as needed. The default is 1 GB.

Disk image size: Specify the size of the disk image.

Disk image location: Specify the location of the Linux volume where containers and images are stored.

You can also move the disk image to a different location. If you attempt to move a disk image to a location that already has one, you get a prompt asking if you want to use the existing image or replace it.

File sharing

Use File sharing to allow local directories on the Mac to be shared with Linux containers.This is especially useful forediting source code in an IDE on the host while running and testing the code in a container.By default the /Users, /Volume, /private, /tmp and /var/folders directory are shared. If your project is outside this directory then it must be addedto the list. Otherwise you may get Mounts denied or cannot start service errors at runtime.

File share settings are:

  • Add a Directory: Click + and navigate to the directory you want to add.

  • Apply & Restart makes the directory available to containers using Docker’sbind mount (-v) feature.

    There are some limitations on the directories that can be shared:

    • The directory must not exist inside of Docker.

For more information, see:

  • Namespaces in the topic onosxfs file system sharing.
  • Volume mounting requires file sharing for any project directories outside of /Users.)

Proxies

Docker Desktop detects HTTP/HTTPS Proxy Settings from macOS and automaticallypropagates these to Docker. For example, if you set yourproxy settings to http://proxy.example.com, Docker uses this proxy whenpulling containers.

Your proxy settings, however, will not be propagated into the containers you start.If you wish to set the proxy settings for your containers, you need to defineenvironment variables for them, just like you would do on Linux, for example:

For more information on setting environment variables for running containers,see Set environment variables.

Network

You can configure Docker Desktop networking to work on a virtual private network (VPN). Specify a network address translation (NAT) prefix and subnet mask to enable Internet connectivity.

Docker Engine

The Docker Engine page allows you to configure the Docker daemon to determine how your containers run.

Type a JSON configuration file in the box to configure the daemon settings. For a full list of options, see the Docker Enginedockerd commandline reference.

Click Apply & Restart to save your settings and restart Docker Desktop.

Command Line

On the Command Line page, you can specify whether or not to enable experimental features.

Experimental features provide early access to future product functionality.These features are intended for testing and feedback only as they may changebetween releases without warning or can be removed entirely from a futurerelease. Experimental features must not be used in production environments.Docker does not offer support for experimental features.

To enable experimental features in the Docker CLI, edit the config.jsonfile and set experimental to enabled.

To enable experimental features from the Docker Desktop menu, clickSettings (Preferences on macOS) > Command Line and then turn onthe Enable experimental features toggle. Click Apply & Restart.

For a list of current experimental features in the Docker CLI, see Docker CLI Experimental features.

On both Docker Desktop Edge and Stable releases, you can toggle the experimental features on and off. If you toggle the experimental features off, Docker Desktop uses the current generally available release of Docker Engine.

You can see whether you are running experimental mode at the command line. IfExperimental is true, then Docker is running in experimental mode, as shownhere. (If false, Experimental mode is off.)

Kubernetes

Docker Desktop includes a standalone Kubernetes server that runs on your Mac, sothat you can test deploying your Docker workloads on Kubernetes.

The Kubernetes client command, kubectl, is included and configured to connectto the local Kubernetes server. If you have kubectl already installed andpointing to some other environment, such as minikube or a GKE cluster, be sureto change context so that kubectl is pointing to docker-desktop:

If you installed kubectl with Homebrew, or by some other method, andexperience conflicts, remove /usr/local/bin/kubectl.

  • To enable Kubernetes support and install a standalone instance of Kubernetesrunning as a Docker container, select Enable Kubernetes. To set Kubernetes as thedefault orchestrator, select Deploy Docker Stacks to Kubernetes by default.

    Click Apply & Restart to save the settings. This instantiates images required to run the Kubernetes server as containers, and installs the/usr/local/bin/kubectl command on your Mac.

    When Kubernetes is enabled and running, an additional status bar item displaysat the bottom right of the Docker Desktop Settings dialog.

    The status of Kubernetes shows in the Docker menu and the context points todocker-desktop.

  • By default, Kubernetes containers are hidden from commands like dockerservice ls, because managing them manually is not supported. To make themvisible, select Show system containers (advanced) and click Apply andRestart. Most users do not need this option.

  • To disable Kubernetes support at any time, clear the Enable Kubernetes check box. TheKubernetes containers are stopped and removed, and the/usr/local/bin/kubectl command is removed.

    For more about using the Kubernetes integration with Docker Desktop, seeDeploy on Kubernetes.

Reset

Reset and Restart options

On Docker Desktop Mac, the Restart Docker Desktop, Reset to factory defaults, and other reset options are available from the Troubleshoot menu.

For information about the reset options, see Logs and Troubleshooting.

Dashboard

The Docker Desktop Dashboard enables you to interact with containers and applications and manage the lifecycle of your applications directly from your machine. The Dashboard UI shows all running, stopped, and started containers with their state. It provides an intuitive interface to perform common actions to inspect and manage containers and existing Docker Compose applications. For more information, see Docker Desktop Dashboard.

Add TLS certificates

You can add trusted Certificate Authorities (CAs) (used to verify registryserver certificates) and client certificates (used to authenticate toregistries) to your Docker daemon.

Add custom CA certificates (server side)

All trusted CAs (root or intermediate) are supported. Docker Desktop creates acertificate bundle of all user-trusted CAs based on the Mac Keychain, andappends it to Moby trusted certificates. So if an enterprise SSL certificate istrusted by the user on the host, it is trusted by Docker Desktop.

To manually add a custom, self-signed certificate, start by adding thecertificate to the macOS keychain, which is picked up by Docker Desktop. Here isan example:

Or, if you prefer to add the certificate to your own local keychain only (ratherthan for all users), run this command instead:

See also, Directory structures forcertificates.

Note: You need to restart Docker Desktop after making any changes to thekeychain or to the ~/.docker/certs.d directory in order for the changes totake effect.

For a complete explanation of how to do this, see the blog post AddingSelf-signed Registry Certs to Docker & Docker Desktop forMac.

Add client certificates

You can put your client certificates in~/.docker/certs.d/<MyRegistry>:<Port>/client.cert and~/.docker/certs.d/<MyRegistry>:<Port>/client.key.

When the Docker Desktop application starts, it copies the ~/.docker/certs.dfolder on your Mac to the /etc/docker/certs.d directory on Moby (the DockerDesktop xhyve virtual machine).

  • You need to restart Docker Desktop after making any changes to the keychainor to the ~/.docker/certs.d directory in order for the changes to takeeffect.

  • The registry cannot be listed as an insecure registry (see DockerEngine. Docker Desktop ignores certificates listedunder insecure registries, and does not send client certificates. Commandslike docker run that attempt to pull from the registry produce errormessages on the command line, as well as on the registry.

Directory structures for certificates

If you have this directory structure, you do not need to manually add the CAcertificate to your Mac OS system login:

The following further illustrates and explains a configuration with customcertificates:

You can also have this directory structure, as long as the CA certificate isalso in your keychain.

To learn more about how to install a CA root certificate for the registry andhow to set the client TLS certificate for verification, seeVerify repository client with certificatesin the Docker Engine topics.

Install shell completion

Docker Desktop comes with scripts to enable completion for the docker and docker-compose commands. The completion scripts may befound inside Docker.app, in the Contents/Resources/etc/ directory and can beinstalled both in Bash and Zsh.

Bash

Bash has built-in support forcompletion To activate completion for Docker commands, these files need to becopied or symlinked to your bash_completion.d/ directory. For example, if youinstalled bash via Homebrew:

Add the following to your ~/.bash_profile:

OR

Zsh

In Zsh, the completionsystem takes care of things. To activate completion for Docker commands,these files need to be copied or symlinked to your Zsh site-functions/directory. For example, if you installed Zsh via Homebrew:

Fish-Shell

Fish-shell also supports tab completion completionsystem. To activate completion for Docker commands,these files need to be copied or symlinked to your Fish-shell completions/directory.

Create the completions directory:

Now add fish completions from docker.

Give feedback and get help

To get help from the community, review current user topics, join or start adiscussion, log on to our Docker Desktop for Macforum.

To report bugs or problems, log on to Docker Desktop for Mac issues onGitHub,where you can review community reported issues, and file new ones. SeeLogs and Troubleshooting for more details.

For information about providing feedback on the documentation or update it yourself, see Contribute to documentation.

Docker Hub

Select Sign in /Create Docker ID from the Docker Desktop menu to access your Docker Hub account. Once logged in, you can access your Docker Hub repositories and organizations directly from the Docker Desktop menu.

For more information, refer to the following Docker Hub topics:

Two-factor authentication

Docker Desktop enables you to sign into Docker Hub using two-factor authentication. Two-factor authentication provides an extra layer of security when accessing your Docker Hub account.

You must enable two-factor authentication in Docker Hub before signing into your Docker Hub account through Docker Desktop. For instructions, see Enable two-factor authentication for Docker Hub.

After you have enabled two-factor authentication:

  1. Go to the Docker Desktop menu and then select Sign in / Create Docker ID.

  2. Enter your Docker ID and password and click Sign in.

  3. After you have successfully signed in, Docker Desktop prompts you to enter the authentication code. Enter the six-digit code from your phone and then click Verify.

After you have successfully authenticated, you can access your organizations and repositories directly from the Docker Desktop menu.

Where to go next

  • Try out the walkthrough at Get Started.

  • Dig in deeper with Docker Labs examplewalkthroughs and source code.

  • For a summary of Docker command line interface (CLI) commands, seeDocker CLI Reference Guide.

  • Check out the blog post, What’s New in Docker 17.06 Community Edition(CE).

mac, tutorial, run, docker, local, machine

PhpStorm is an Integrated Development Environment for PHP developers built on top of the IntelliJ IDEA platform.

Supported languages

With PhpStorm, you can develop applications in PHP 5.3, PHP 5.4, PHP 5.5, PHP 5.6, PHP 7, PHP 7.1, PHP 7.2, PHP 7.3, and PHP 7.4. In addition, it fully supports HTML5, CSS, JavaScript, and XML: support for these languages is handled via plugins that are bundled in the IDE and are enabled by default. Support for other languages can be added via plugins: in the Settings/Preferences dialog Ctrl+Alt+S, go to Plugins to find out more or set them up during the first IDE launch.

Supported platforms

PhpStorm is a cross-platform IDE that works on Windows, macOS, and Linux.

System requirements

RequirementMinimumRecommended
RAM2 GB of free RAM8 GB of total system RAM
Disk space2.5 GB and another 1 GB for cachesSSD drive with at least 5 GB of free space
Monitor resolution1024x7681920×1080
Operating system

Officially released 64-bit versions of the following:

  • Microsoft Windows 8 or later

  • macOS 10.13 or later

  • Any Linux distribution that supports Gnome, KDE , or Unity DE

Pre-release versions are not supported.

Latest 64-bit version of Windows, macOS, or Linux (for example, Debian, Ubuntu, or RHEL)
Macos Docker For Php Development Tutorial

You do not need to install Java to run PhpStorm, because JetBrains Runtime is bundled with the IDE (based on 11).

Configuring PHP environment

PhpStorm is a smart IDE, but first you need to inform it which PHP environment we use, where PHP components are stored, and how they are configured.

  • If you work with a local Web server, follow the Install an AMP package procedure to prepare your environment.

  • If you work in a Docker container, see Docker Support in PhpStorm.

  • If you use Vagrant, see Vagrant Support in PhpStorm.

In this Quick Start Guide, we will set up a pre-configured project in a Docker environment.

Before you start

  1. Install Docker for your operating system.

  2. In PhpStorm, in the Settings/Preferences dialog Ctrl+Alt+S, go to Build, Execution, Deployment Docker and select how to connect to the Docker daemon.

    Depending on your operating system, do the following:

    • Select TCP socket.

    • Set Engine API URL to tcp://localhost:2375.

      In the General section of Docker for Windows settings, enable Expose daemon on tcp://localhost:2375 without TLS.

    • Leave the Certificates folder field empty.

    If you are using Docker Toolbox, use the following configuration options instead:

    • Set Engine API URL to https://192.168.99.100:2376

    • Set Certificates folder to <your_home_directory>.dockermachinemachinesdefault.

    • Select Unix socket.

Step 1: Open a project in PhpStorm

Everything you do in PhpStorm is done within the context of a project. It serves as a basis for coding assistance, bulk refactoring, coding style consistency, and so on.

In this Quick Start Guide, we provide a workshop project that already contains a docker-compose.yml file with the pre-configured environment. The project is available on GitHub at https://github.com/JetBrains/phpstorm-workshop.

Start the Workshop project in PhpStorm

  1. On the PhpStorm Welcome screen, click Create New Project.

  2. Select PhpStorm Workshop Project from the list on the left, provide the project location in the Location field, and click Create.

  3. Open docker-compose.yml in the editor and update the XDEBUG_CONFIG variable with the value depending on your operating system. This is necessary for Web Debugging.

    Use the host.docker.internal value, which refers to the remote host, that is, the machine Docker is running on. It will automatically resolve to the internal address of the host, letting you connect to it from the container.

    The corresponding part of the docker-compose.yml file should look as follows:

    Use the host.docker.internal value, which refers to the remote host, that is, the machine Docker is running on. It will automatically resolve to the internal address of the host, letting you connect to it from the container.

    The corresponding part of the docker-compose.yml file should look as follows:

    Use your local machine’s hostname. To obtain it, execute the hostname command in Terminal.

    The corresponding part of the docker-compose.yml file should look as follows:

  4. In the same docker-compose.yml file, uncomment the appropriate line for the sftp service depending on your operating system. This is necessary for deployment to work correctly.

  5. Click in the editor gutter to start all required Docker containers.

    Alternatively, open the built-in PhpStorm Terminal (Alt+F12) and execute the docker-compose up command.

You have other options to start working on a project in PhpStorm as you can see from the Welcome Screen:

Step 2: Explore the user interface

The main PhpStorm window is divided into several logical areas:

  1. Menus and toolbars that help us execute various commands.

  2. Navigation bar for navigating through the project.

  3. Status bar with various information about the entire PhpStorm, the current project or a file in the editor, warnings, and error messages.

  4. The Editor where you actually write your code. It has tabs for easy navigation between opened files.

  5. Numerous Tool Windows that perform different functions: help you explore and navigate through the project and file structures, view search and inspection results, run, debug, and test applications, work in interactive consoles, and more.

Step 3: Code with smart assistance

PhpStorm takes care of the routine so that you can focus on the important. Use numerous PhpStorm coding capabilities to create error-free applications without wasting precious time. In the base project, you can interactively try these features on a number of PHP files with code examples and guidelines.

Code completion

Code completion is a great time-saver regardless of the type of the file you’re working with. There are two types of code completion in PhpStorm: basic and smart.

Basic completionCtrl+Space shows the code completion options for the current context and displays the members of the current type in bold: Does venmo for ios work for macos.

To have more variants shown, press Ctrl+Space again.

To try basic code completion, open workshop/02_Editing/01_Completion/1.1_Basic_Completion.php in your project and follow the instructions in the comments.

Smart completionCtrl+Shift+Space analyzes the context you’re currently working in and offers more accurate suggestions based on that analysis filtering the list of functions and variables to match the expression type.

To try smart code completion, open workshop/02_Editing/01_Completion/1.3_Type_hinting.php in your project and follow the instructions in the comments.

Intention actions

PhpStorm keeps an eye on what you are currently doing and makes smart suggestions, called intention actions, to save more of your time. Intention actions let you apply automatic changes to the code that is correct (in contrast to code inspections that provide quick-fixes for code that may be incorrect).

Your code references a file that does not exist? Not a problem with PhpStorm. Press Alt+Enter and choose Create file <filename>:

To view the full list of available intention actions, in the Settings/Preferences dialog Ctrl+Alt+S go to Editor Intentions.

To try various intention actions, open workshop/02_Editing/05_Intentions/5.1_Intentions.php in your project and follow the instructions in the comments.

Step 4: Keep your code neat

PhpStorm monitors your code and tries to keep it accurate and clean. It detects potential errors and problems and suggests quick-fixes for them.

Every time PhpStorm finds unused code, an endless loop, hidden upper scope, an assignment operator = in a conditional expression, and many other things that probably require your attention, you’ll see a light bulb. Click it, or press Alt+Enter, to apply a fix.

You forgot a use statement?

Press Alt+Enter and click Import class:

In the list, click the class to import:

PhpStorm imports the selected class and adds a use statement:

Try more live examples from workshop/03_Inspections/02_Quick_Fixes.php.

To view the full list of available inspections, in the Settings/Preferences dialog Ctrl+Alt+S go to Editor Inspections. You can disable some of them, or enable others, plus you can adjust the severity of each inspection. You decide whether it should be considered an error or just a warning.

Step 5: Generate some code

Writing code can be a lot easier and faster with the code generation options available in PhpStorm. The Code Generate menu (or just Alt+Insert) will help you with generating constructors, getters/setters, PHPDoc comments as well as suggest overriding/implementing some methods Ctrl+O / Ctrl+I. Try more live examples in workshop/02_Editing/06_Generate_code/6.1_Generate_Code.php.

Use live templates (choose Code Insert Live Template or press Ctrl+J) to produce entire code constructs. To view the list of available ready-to-use live templates, in the Settings/Preferences dialog Ctrl+Alt+S go to Editor Live templates.

If you see that you need something important for your development, extend this set of templates with your own ones. Try live examples from workshop/04_Live_Templates/01_Code_Expansion/1.1_Code_Expansion.php and workshop/04_Live_Templates/02_Creating_Live_Templates.

Also, consider surrounding your code with complete constructs. Choose Code Surround With or press Ctrl+Alt+T, then choose the required statement from the popup menu. Try more live examples in workshop/04_Live_Templates/03_Surround_Templates/3.1_Simple_template.php.

Step 6: Find your way through

When your project is big, or when you have to work with the code written by someone else, it’s vital to be able to quickly find what you are looking for and dig into the code. This is why PhpStorm comes with a set of navigation features that will help you find your way through code.

Basic search

Docker Tutorial Pdf

To find where a particular symbol is used in your project, PhpStorm suggests full-scale search via Find UsagesAlt+F7:

Macos Docker For Php Development Tutorial For Beginners

You can also search only in the current file Ctrl+F, or within a directory, any arbitrary scope, or the entire project Ctrl+Shift+F.

To try basic search, open workshop/01_Navigation/05_Find_usages/5.2_Find_Usages.php or workshop/01_Navigation/05_Find_usages/5.1_Highlight_Usages_in_File.php in your project and follow the instructions in the comments.

Project navigation

You can tell a lot just looking at your File Structure, with its imports or call hierarchies, and possibly use it to navigate through your code with the help of powerful navigation actions.

  • Search Everywhere lets you search for classes, file, symbols and menu actions all at once as well as navigate to them. To launch Search Everywhere, click the magnifying glass icon in the upper-right corner of the PhpStorm window or press Shift twice. If you do not specify any search pattern, PhpStorm shows a list of recent files where you can navigate to the relevant item by clicking it:

    To search for something specific, type a search pattern. Note that besides symbols, Search Everywhere can find actions:

    In the Search Everywhere mode, PhpStorm even accepts CamelHumps and recognizes middle matches.

    To try various ways to use Search Everywhere, open workshop/01_Navigation/01_Navigate_to_something_you_know/1.6_Search_everywhere.md in your project and follow the instructions.

    Of course navigation to a ClassCtrl+N, a FileCtrl+Shift+N, or a SymbolCtrl+Alt+Shift+N by its name is also at your disposal, see Searching Everywhere.

  • Go To Declaration (Ctrl+B, Ctrl+Click) brings you to the location where a particular symbol is first declared. This type of navigation works from any place in the source code, even from another class or comment. To try navigating through Go to Declaration, open workshop/01_Navigation/02_Navigate_to_Declaration/2.1_Go_to_declaration.php in your project and follow the instructions in the comments.

  • Go to ImplementationCtrl+Alt+B brings you to the implementation of a particular class. If there are several implementations, PhpStorm shows them in a list where you can select the relevant one to navigate to. To try navigating through Go to Implementation, open workshop/01_Navigation/04_Navigate_class_hierarchies/4.1_Go_to_Implementation.php in your project and follow the instructions in the comments.

Navigate through the timeline

PhpStorm automatically keeps track of the changes you make to the source code, the results of refactoring, and so on in the Local History. Contrary to traditional Version Control Systems, Local History is always enabled. To view it for a file or a folder, choose VCS Local History Show History from the main menu. Here you can review the changes, revert them (), or create a patch ():

To try using Local History yourself, open workshop/09_Version_Control/07_Local_History.php in your project and follow the instructions in the comments.

Step 7: Debug your application

Macos Docker For Php Development Tutorial Pdf

Does your application do exactly what it is intended to? If it does not, you will have to do some debugging to find out what causes the problem. Luckily, our sample project already has Xdebug installed and configured.

Configure the PHP interpreter

In our project, the Docker environment already contains a PHP interpreter, and you only need to tell PhpStorm where it is located.

  1. In the Settings/Preferences dialog Ctrl+Alt+S, go to Languages and Frameworks PHP.

  2. On the PHP page that opens, select PHP 7.1 with Xdebug from the CLI Interpreter list.

Set breakpoints

Debugging starts with placing breakpoints at which program execution will be suspended, so you can explore program data. Just click the left gutter of the line where you want the breakpoint to appear:

To play with breakpoints yourself, open workshop/06_Debugging/03_Breakpoints.php in your project and follow the instructions in the comments.

Start debugging

In the Project tool window, select workshop/06_Debugging/03_Breakpoints.php and choose Debug 03_Breakpoints.php from the context menu:

PhpStorm starts a debugging session and opens the Debug tool window where you can step through the suspended program, view variable values, evaluate expressions, and much more. Try more live examples from workshop/06_Debugging/05_Debug_Tool_Window.php.

See Zero-configuration debugging for alternative debugging scenarios.

Step 8: Test your code

PhpStorm integrates with the most popular PHP test frameworks: such as PHPUnit, Behat, PHPSpec, and Codeception.

Write your tests

Navigate to the class to test and press Ctrl+Shift+T. From the popup list, choose Create New Test:

In the dialog that opens, all the fields are filled in so just click OK. PhpStorm generates a test class <class_to_test>Test and opens it in the editor. Write your tests as required.

To try writing tests yourself with PhpStorm coding assistance, open workshop/08_Testing/01_Writing_Tests.php and follow the instructions in the comments.

Launch the test

Open the file with your tests in the editor or click it in the Project tool window and choose Run <class_to_test>Test. This launches the PHPUnit run configuration that PhpStorm has generated for you automatically. You can also create a run configuration (Run Edit Configurations) of the Behat, PHPSpec, or Codeception type, select it from the list on the toolbar, and then click . PhpStorm shows the results in the Test Runner tab of the Run tool window.

Step 9: Keep your source code under Version Control

If you are keeping your source code under version control, you will be glad to know that PhpStorm integrates with many popular version control systems: Git (or GitHub), Mercurial, Perforce, and Subversion. To specify credentials and any settings specific to a particular VCS, in the Settings/Preferences dialog Ctrl+Alt+S go to Version Control.

The VCS menu will give you a clue about what commands are available. For example, you can see the changes you’ve made, commit them, create changelists and much more from the Changes popup view (VCS Show Changes View or Alt+9).

Step 10: That’s it! Go ahead and develop with pleasure!

We hope this brief overview of essential PhpStorm features will give you a quick start. There are many important features that make a developer’s life easier and more fun, and their source code neater and cleaner. Take these first few steps now, and then dig deeper when you feel the time is right. Enjoy PhpStorm!

With any questions visit our PhpStorm Discussion Forum, twitter, and blog, where you can find news, updates, and useful tips and tricks. Also, don't hesitate to report any problems to our support team) or the PhpStorm issue tracker.

Last modified: 14 May 2020