×ðÁú¿­Ê±¹ÙÍøµÇ¼

½Ì³Ì£ºÊ¹ÓÃDockerÈÝÆ÷»¯×°ÖÃSymfony

½Ì³Ì£ºÊ¹ÓÃDockerÈÝÆ÷»¯×°ÖÃSymfony

СÐò£º

DockerÊÇÒ»ÖÖ¿ªÔ´µÄÈÝÆ÷»¯Æ½Ì¨ £¬¿ÉÒÔ×ÊÖú¿ª·¢Õß¿ìËÙ¹¹½¨¡¢´ò°üºÍ°²ÅÅÓ¦ÓóÌÐò¡£SymfonyÊÇÒ»¸öÊ¢ÐеÄPHP¿ò¼Ü £¬ÌṩÁËÐí¶à¹¦Ð§Ç¿Ê¢µÄ¹¤¾ßºÍ×é¼þ £¬ÓÃÓÚ¿ª·¢¸ßÐÔÄܵÄWebÓ¦ÓóÌÐò¡£ÔÚ±¾½Ì³ÌÖÐ £¬ÎÒÃǽ«ÏÈÈÝÔõÑùʹÓÃDockerÈÝÆ÷»¯×°ÖÃSymfony £¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¹©²Î¿¼¡£

°ì·¨Ò»£º×°ÖÃDockerºÍDocker Compose

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÔÚÎÒÃǵĿª·¢»úеÉÏ×°ÖÃDockerºÍDocker Compose¡£Çëƾ֤Docker¹Ù·½ÎĵµÖеÄ˵Ã÷¾ÙÐÐ×°Öá£

°ì·¨¶þ£º½¨ÉèSymfonyÏîÄ¿

ÔÚ×îÏÈ֮ǰ £¬ÎÒÃÇÐèÒª½¨ÉèÒ»¸öSymfonyÏîÄ¿¡£·­¿ªÖÕ¶Ë £¬²¢Ö´ÐÐÒÔÏÂÏÂÁ

$ composer create-project symfony/skeleton symfony_project

µÇ¼ºó¸´ÖÆ

Õ⽫ÔÚÄ¿½ñĿ¼Ï½¨ÉèÒ»¸öÃûΪsymfony_projectµÄSymfonyÏîÄ¿¡£

°ì·¨Èý£º½¨ÉèDockerÎļþ

ÔÚÓëSymfonyÏîĿͬ¼¶µÄĿ¼Ï £¬½¨ÉèÒ»¸öÃûΪdocker-compose.ymlµÄÎļþ £¬²¢Ìí¼ÓÈçÏÂÄÚÈÝ£º

version: '3.8'
services:
  web:
    image: php:7.4-apache
    volumes:
      - ./symfony_project:/var/www/html
    ports:
      - 8080:80
    depends_on:
      - database

  database:
    image: mysql:5.7
    environment:
      - MYSQL_DATABASE=your_database_name
      - MYSQL_USER=your_username
      - MYSQL_PASSWORD=your_password
      - MYSQL_ROOT_PASSWORD=your_root_password
    volumes:
      - ./mysql:/var/lib/mysql

µÇ¼ºó¸´ÖÆ

ÇëÈ·±£½«your_database_name £¬your_username £¬your_passwordºÍyour_root_passwordÌ滻ΪÄã×Ô¼ºµÄÊý¾Ý¿âÃû³Æ¡¢Óû§Ãû¡¢ÃÜÂëºÍÖÎÀíÔ±ÃÜÂë¡£

°ì·¨ËÄ£º¹¹½¨ºÍÔËÐÐDockerÈÝÆ÷

ÔÚÖÕ¶ËÖÐ £¬µ¼º½µ½°üÀ¨docker-compose.ymlÎļþµÄĿ¼ £¬²¢Ö´ÐÐÒÔÏÂÏÂÁ

$ docker-compose up -d

µÇ¼ºó¸´ÖÆ

Õ⽫¹¹½¨ºÍÔËÐÐDockerÈÝÆ÷¡£-dÑ¡ÏÈÝÆ÷ÒÔºǫ́ģʽÔËÐС£

°ì·¨Î壺»á¼ûSymfonyÓ¦ÓóÌÐò

·­¿ªä¯ÀÀÆ÷ £¬²¢»á¼ûhttp://localhost:8080¡£ÄãÓ¦¸ÃÄܹ»¿´µ½SymfonyµÄ½Ó´ýÒ³Ãæ¡£ÏÖÔÚ £¬Äã¿ÉÒÔ×îÏÈÔÚSymfonyÏîÄ¿ÖоÙÐпª·¢ºÍ²âÊÔÁË¡£

°ì·¨Áù£ºÍ¨¹ýÏÂÁîÐлá¼ûSymfonyÈÝÆ÷

ÈôÊÇÄãÐèÒªÔÚSymfonyÈÝÆ÷ÄÚÖ´ÐÐÏÂÁî £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

$ docker-compose exec web bash

µÇ¼ºó¸´ÖÆ

Õ⽫½øÈëSymfonyÈÝÆ÷µÄbash shell¡£ÔÚÕâ¸öshellÖÐ £¬Äã¿ÉÒÔÖ´ÐÐÈκÎÓëSymfonyÏîÄ¿Ïà¹ØµÄÏÂÁî¡£

¿¢ÊÂÓ

ͨ¹ýʹÓÃDockerÈÝÆ÷»¯×°ÖÃSymfony £¬ÎÒÃÇ¿ÉÒÔ¿ìËٴºÍÖÎÀíSymfonyÏîÄ¿µÄ¿ª·¢ÇéÐÎ £¬ïÔÌ­ÁËÇéÐÎÉèÖÃÎÊÌâ´øÀ´µÄƶÀ§ £¬²¢Ìá¸ßÁË¿ª·¢Ð§ÂÊ¡£Ï£Íû±¾½Ì³ÌÄܶÔÄãÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊǽ̳̣ºÊ¹ÓÃDockerÈÝÆ÷»¯×°ÖÃSymfonyµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ