Skip to content

Instantly share code, notes, and snippets.

@toioski
Last active April 9, 2021 08:45
Show Gist options
  • Save toioski/6abafbe5e83227c9f5304d7679340c27 to your computer and use it in GitHub Desktop.
Save toioski/6abafbe5e83227c9f5304d7679340c27 to your computer and use it in GitHub Desktop.
Create and run a Sylius project on macOS

Create and run a Sylius project on macOS

Create the project

  • Install PHPBrew to manage multiple PHP versions

  • Install Docker

  • Install globally the library Argon2 used by PHP for password hashing. It must be installed globally because it's used to build PHP itself.

    brew install argon2
    
  • Install with PHPBrew a version of PHP compatibly with Sylius (^7.2)

    phpbrew install 7.4.16 +default +intl +pdo +mysql +gd +exif -- --with-password-argon2
    
  • Check that PHPBrew installated the version correctly and set it as the default PHP binary

    phpbrew list
    phpbrew switch 7.4.16
    
  • Check that PHP 7.4.16 is working fine

    php --version
    
  • Modify the php.ini with phpbrew config changing the following keys

    memory_limit=2G
    date.timezone="Europe/Berlin"
    
  • Create a Docker container to handle MySQL

    docker run -p 3306:3306 --name sylius-course-db -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7
    
  • Check that the container sylius-course-db is running fine

    docker ps
    

    and check that you can reach the DB with Sequel Pro (for example)

    host: 127.0.0.1
    username: root
    password: root
    port: 3306
    
  • Install Symfony CLI

  • Create the Sylius project

    composer create-project sylius/sylius-standard SyliusCourse
    

    N.B. If the installation fails because you're missing some PHP extension (e.g. Install or enable PHP's gd extension), you can run

    phpbrew ext install <name of the extension>
    
  • Change the database configuration inside the file .env

    DATABASE_URL=mysql://root:root@127.0.0.1:3306/sylius_course_%kernel.environment%
    
  • Install Sylius

    cd SyliusCourse
    php bin/console sylius:install
    

    N.B. If you have an error with the PHP's extension intl, then follow this Github's thread to install it correctly.

  • Install the frontend dependencies and then build the assets

    yarn install
    yarn run gulp
    
  • Run the Symfony local server and enjoy!

    symfony server:start
    open http://127.0.0.1:8000
    

Setup PHPStorm

  • Enable the Symfony plugin for the project going to Languages & Frameworks -> PHP -> Symfony -> Enable Plugin for this Project

  • Open package.json and add this into the script section:

    "symfony:start": "symfony server:start"
    
  • Go into Run/Debug configurations and

    • add an npm action to run the script symfony:start
    • add an npm action to run the script watch
    • add a Compound action to run the two npm actions
  • Go to View -> Tool Windows -> Database to show the Database panel:

    • tap + symbol to add a MySQL database
    • set Host: localhost
    • set User: root
    • set Password: root
    • set Port: 3306
    • set Database: sylius_course_dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment