moving custom symfony bundle to vendor folder - symfony

I am currently reorganising my Symfony project in which there are various custom bundles.
Can anyone advise as to when do you move a custom bundle from the src/ folder to the vendor/ folder (by loading it through composer).

Related

Add custom .gitignore file to list of templates

My organization hosts its own GitHub Enterprise instance. Is it possible to add a new .gitignore file to the list of templates when creating a new repository?

Silverstripe v4 MVC Directories?

I'm Wondering Why There is no "Models / Views / Controllers" Directories Inside SS4 Main Directory? It's Seems Like Everything Should Go Inside "mysite/code" .. How To Accomplish MVC Style?
MVC is more of a software-architectural pattern, not how you organize files. There are only a few assumptions the SilverStripe framework makes on how you should organize your code:
Model
With SilverStripe 4, the default code folder for every module is named src or code. In that folder you're free to organize your files as you see fit. Ideally you build your folder structure in a PSR-4 compliant way, so that your folder-names match with your namespaces.
Controllers
Same as with Model classes, you can put your controllers anywhere you want.
There's a default assumption for Page classes though. These expect that the matching controller has the same namespace as the page. So if your page is named: Company\Module\Pages\MyPage, the framework would look for Company\Module\Pages\MyPageController.
You're free to override that though, by implementing the getControllerName method on your Page and return the FQCN for the controller to use.
Views
Also known as "templates" should be in a templates folder. Each module (your mysite folder is also a module) can have a templates folder.
In addition to this, you can have themes. Themes usually bundle templates, css and other assets. In the themes folder you can have multiple theme folders, each one can have a templates folder.

Use bundle error templates in Symfony 3 app

I have a MyBundle bundle which I use in many Symfony applications.
This bundle provides common things which are shared across these applications, such as Controllers, Entities, templates, etc.
I would like the bundle to provide error templates as well.
I tried to put the templates in MyBundle/Resources/TwigBundle/views/Exception folder but the application does not use them.
When I copy TwigBundle folder from MyBundle/Resources into app/Resources then the templates are used as expected. However I do not want to copy the templates into every application's app/Resources folder.
Is it possible to override error templates using MyBundle/Resources instead of app/Resources?
TwigBundle always by default checks directory app/Resources/TwigBundle/views/Exception/ for templates.
If you want to use custom directory you have to override ExceptionController.
You can do this in config
// app/config/config.yml
twig:
exception_controller: MyBundle:Exception:showException
Default Twig ExceptionController can be found here.
Documentation

Install components via Bower without SSL in ASP.NET 5 Starter Web project

Due to corporate proxy issues I am unable to download components via Bower using https.
I know that normally you can get around this by adding
"registry": "http://bower.herokuapp.com"
to the .bowerrc file, but I can't seem to find it anywhere.
Please note that I haven't had Bower installed locally (as I am not intended to). I got bower.json from using the new ASP.NET 5 starter Web Project which has popular tools like Grunt and Bower built-in.
I wonder where this file is, or if there is any other way to replace https with http in the download url?
Update
I had to create the .bowerrc file manually and placed it inside the project root.
{
"directory": "wwwroot",
"registry": "http://bower.herokuapp.com"
}
Make sure you have wwwroot there as the directory. Doing this the output will now show with http.
However, this still doesn't resolve my problem - Bower still cannot download anything, nor can nuget. This is really strange 'cause if I create a normal web project using VS2015, nuget works fine...
The .bowerrc file can be located in one of the following:
Local .bowerrc located in the current working directory
All .bowerrc files upwards the directory tree
.bowerrc file located in user’s home folder (%USERPROFILE%)
bowerrc (without the dot) file located in %APPDATA%/bower/config
But setting the bower registry URL is probably not enough as bower will still need the https protocol in order to fetch package content from Github.

What's the point of subfolders in src folder

I need to create three folders in my project. In each of them I'd have to create a couple of subfolders containing proper classes.
So what is the point of creating a subfolder for all bundles in the SRC folder?
I mean, I'm dividing my project into Folder1Bundle, Folder2Bundle etc...So the folder structure would be:
src/ProjectName/Folder1Bundle
src/ProjectName/Folder2Bundle
etc.
And the src folder will contain only ProjectName folder...What's the point of creating big folders for bundle folders, instead of putting all bundles directly into the SRC folder?
Take a look in the best practices for structuring bundles.
A bundle is also a PHP namespace. The namespace must follow the technical interoperability standards for PHP 5.3 namespaces and class names: it starts with a vendor segment, followed by zero or more category segments, and it ends with the namespace short name, which must end with a Bundle suffix.
So the vendor name (ProjectName in your case) is for structuring namespace and get no conflicts with naming of other namespaces and symfony bundles.
Oh, and very important, the directory structure reflects your php namespace 1:1

Resources