symfony框架学习
创建项目
composer create-project symfony/skeleton:"^5.4" symfony_test
cd symfony_test
composer require webapp
D:\workspace>cd symfony_test
composer update
composer install
添加controller和路由
集中式路由:/config/routes.yaml
路由:/src/Controller
启动服务
symfony server:stop
symfony server:start
添加orm支持
composer require symfony/orm-pack
composer require symfony/maker-bundle --dev
运行以下命令创建一个名为Article的实体:
php bin/console make:entity Article
运行以下命令生成迁移文件:
php bin/console make:migration
运行以下命令执行迁移,将变更应用到数据库:
php bin/console doctrine:migrations:migrate
使用Doctrine命令生成数据库表(这个要慎用):
php bin/console doctrine:schema:update --force
练习的几个功能
https://symfony.com/doc/current/page_creation.html
操作数据库
https://symfony.com/doc/current/doctrine.html
https://blog.csdn.net/FLK_9090/article/details/140208368
本文来自博客园,作者:河北大学-徐小波,转载请注明原文链接:https://www.cnblogs.com/xuxiaobo/p/18606801