Prerequisites
- installed XAMPP or MAMP (apache server & php installation bundles)
- installed composer (php libraries)
- installed npm (deploy libraries)
Step 1: install Symfony installer
option 1 (recommended): download the installer, and move it to the directory where your repository should be located
php -r "readfile('https://symfony.com/installer');" > symfony move symfony D:\Repos php symfony new my_project
option 2: create the project with composer:
composer create-project symfony/framework-standard-edition my_project
follow the instructions in the console (you will probably need to configure your database & mail settings)
now, update all packages with composer:
composer update
Step 2: set up npm
create a file named package.json
, adapt following json to your needs:
{ "name": "my_project", "version": "0.1.0", "description": "My Project", "repository": { "type": "git", "url": "git://github.com/famoser/my_project.git" }, "keywords": [ "office", "online" ], "author": "Florian Moser <git@famoser.ch>", "license": "MIT", "bugs": { "url": "https://github.com/famoser/my_project/issues" }, "homepage": "https://github.com/famoser/my_project", "devDependencies": { "bower": "^1", "browser-sync": "^2", "del": "^2", "gulp": "^3", "gulp-all": "^1", "gulp-batch": "^1", "gulp-bower": "^0", "gulp-clean-css": "^2", "gulp-concat": "^2", "gulp-less": "^3", "gulp-notify": "^2", "gulp-rename": "^1", "gulp-sass": "^2", "gulp-sourcemaps": "^1", "gulp-uglify": "^1", "gulp-watch": "^4", "less-plugin-autoprefix": "^1", "rimraf": "^2" } }
run in your console
npm update
Step 3: set up bower
create a file named bower.json
, adapt following json to your needs:
{ "name": "my-project", "version": 0.1, "homepage": "https://github.com/famoser/my-project", "authors": [ "famoser <git@famoser.ch>" ], "description": "My Project", "keywords": [ "php" ], "license": "MIT", "ignore": [ "**/.*", "node_modules", "bower_components", "test", "tests" ], "dependencies": { "jquery": "2.2.3", "bootstrap": "3.3.6", "components-font-awesome": "*" } }
create a file named .bowerrc
, with following json content:
{ "directory": "web/assets/vendor/" }
to create such a strange filename you can run
copy NUL > .bowerrc
in your console.
Step 4: set up build tools
I’ll use gulp
for this.
Create a file named guldfile.js
, content must be JavaScript. You’ll find a good starting point here: gist. There is quite a lot going on in this file, the instructions and the configuration is at the top.
Now run in your console
gulp
to build all frontend libraries for the first time.
Step 5: set up source control
- add a README.MD describing your project
- add a LICENSE.MD so other users may or may not be allowed to use your work (I’m recommending the MIT license)
- exclude unnecessary files from git (bower, composer & IDE files)
.idea node_modules /web/assets/vendor symfony-scripts/.git
Step 6: rename your AppBundle
choose a custom name for your application, make it VendorApplicationBundle, so for example GoogleYoutubeBundle.
Files / Folder you need to adapt:
- The file
/src/AppBundle/AppBundle.php
- The namespaces in all
.php
files inside/src/AppBundle/**/*.php
- The folder
/src/AppBundle
- in
/app/AppKernel.php
you need to register your renamed bundle (just replace the oldAppBundle/AppBundle
entry)