If you liked what you've learned so far, dive in!
Subscribe to get access to this tutorial plus
video, code and script downloads.
With a Subscription, click any sentence in the script to jump to that part of the video!
Login SubscribeWe're on a mission to remove the last parts of our Symfony 3 structure!
So what about the DoctrineMigrations
directory? Look in src/
. Interesting... the DoctrineMigrationsBundle recipe added a Migrations/
directory. So, I guess that's where they go!
Copy all of the migration files and paste them there. I guess that worked? Let's find out:
./bin/console doctrine:migrations:status
Ah! I guess not! It says that my migration class wasn't found: Is it placed in a DoctrineMigrations
namespace? Bah! I don't know!
Our files have an Application\Migrations
namespace. What's going on? Open the config/packages/doctrine_migrations.yaml
file.
Ah ha! The recipe installed config that told the bundle to expect a DoctrineMigrations
namespace. Easy fix! Copy the current namespace, and paste it here.
doctrine_migrations: | |
... lines 2 - 4 | |
namespace: 'Application\Migrations' |
Try the command again:
./bin/console doctrine:migrations:status
Life is good! Well, we don't have a database - but life is still pretty good.
At this point, app/
only has 3 files left: AppKernel
, AppCache
and autoload.php
. And unless you made some crazy customizations to these, you don't need any of them. Yes, I'm telling you to delete the app/
directory!
And in composer.json
, remove the classmap
line: those files are gone!
Let's reset our files and look at each directory one by one. We need bin/
, config/
and public/
is the new document root. src/
holds our code, and templates/
, tests/
and translations/
are all valid Flex directories. Oh, and tutorial/
? Ignore that: I added that for this course - it has a file we'll use later.
But expand var/
. Delete everything except for cache
and log
: the default logs directory was renamed in Flex. And that bootstrap file is a relic of the past!
And finally.... web/
! This directory should not exist. Select the files we need: css/
, images/
, js/
and vendor/
: move these into public/
. Let's also move robots.txt
.
And that's it! The favicon
is from Symfony and we don't need the app files anymore. What about .htaccess
? You only need that if you use Apache. And if you do, Flex can add this file for you! Just run composer require symfony/apache-pack
. The recipe will add this inside public
.
Anyways, delete web/
! This is it! Our app is fully in Flex! And we didn't even need to move all our files from src/AppBundle
... though we will do that soon. And as far as bin/console
is concerned, the app works!
But to really prove it's alive, let's try this in a browser and handle a few last details. That's next!
Hey Hendra
Could you elaborate a bit more? Under what circumtances do you get that error?
Double-check that your database credentials are correct.
Cheers!
// composer.json
{
"require": {
"php": "^7.1.3",
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/doctrine-bundle": "^1.6", // 1.8.1
"doctrine/doctrine-cache-bundle": "^1.2", // 1.3.2
"doctrine/doctrine-migrations-bundle": "^1.1", // v1.3.1
"doctrine/orm": "^2.5", // v2.7.2
"fzaninotto/faker": "^1.7", // v1.7.1
"knplabs/knp-markdown-bundle": "^1.4", // 1.6.0
"sensio/framework-extra-bundle": "^5.0", // v5.1.3
"stof/doctrine-extensions-bundle": "dev-master", // dev-master
"symfony/asset": "^4.0", // v4.0.1
"symfony/console": "^4.0", // v4.0.1
"symfony/flex": "^1.0", // v1.9.10
"symfony/form": "^4.0", // v4.0.1
"symfony/framework-bundle": "^4.0", // v4.0.1
"symfony/lts": "^4@dev", // dev-master
"symfony/maker-bundle": "^1.0", // v1.0.2
"symfony/monolog-bundle": "^3.1", // v3.1.2
"symfony/polyfill-apcu": "^1.0", // v1.6.0
"symfony/profiler-pack": "^1.0", // v1.0.3
"symfony/security-bundle": "^4.0", // v4.0.1
"symfony/security-csrf": "^4.0",
"symfony/swiftmailer-bundle": "^3.1", // v3.1.6
"symfony/translation": "^4.0", // v4.0.1
"symfony/twig-bundle": "^4.0", // v4.0.1
"symfony/validator": "^4.0", // v4.0.1
"symfony/web-server-bundle": "^4.0", // v4.0.1
"symfony/yaml": "^4.0" // v4.0.1
},
"require-dev": {
"symfony/dotenv": "^4.0", // v4.0.1
"symfony/phpunit-bridge": "^4.0", // v4.0.1
"doctrine/doctrine-fixtures-bundle": "^3.0" // 3.0.2
}
}
I got error
An option named "connection" already exists.
any Idea?