May I change the default Symfony2 structure to fit my needs?
I like the follow structure, but don't know how to get it to working..
core/ <- Symfony2 core files
app/ <- All applications
app/Acme/ <- Application for Acme enterprise (with all bundles..)
app/clientone.com/ <- Application for Client One enterprise (with all bundles..)
Inside symfony2 distribution there are 4 main directories:
app (there are customisations to your app)
vendors (symfony and other libraries)
src (your source code which may or may not to be application specific,
there could be bundle ClientoneBundle which is specific to only this application,
but also could be a bundle reused among your applications,- such as UserBundle)
web (http document root)
So if you have several applications you could keep vendors separately. And each of your application may contain three directories like:
- apps/acme/app
- apps/acme/src
- apps/acme/web
- apps/clientone/app
- apps/clientone/src
- apps/clientone/web
- some/where/else/in/filesystem/vendor
To implement such setup is very easy,- all you have to do is edit your autoload.php (which resides in app dir), just replace everywhere __DIR__.'/../vendor to __DIR__.'/../vendor,
in other words, tell symfony2 that you moved vendors somewhere else.
(I just renamed app directory in your setup to apps - to be not confused with app directory, inside each of your application)
Related
Please guide me about the hierarchy of Yii Framework i.e in which directory do we put html, css, javascript files and associate them with each other.
You may check the documentation (http://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-site/)
To answer your question:
backend: the backend application which is mainly used site
administrators to manage the whole system.
frontend: the frontend
application which provides the main interfaces to our target end
users.
console: the console application that consists of the console
commands needed by the system.
common: the directory whose content are
shared among the above applications. As we can see, we divide the
whole system into three applications: backend, frontend and console.
If needed, we can add more applications (e.g. api, to provide Web API
service). We use common to store files that are shared among the
applications.
As you have tagged the question with Yii2 as well, here is the typical directory strucuture of Yii2 Advanced Template:
https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/structure-directories.md
Directories
The root directory contains the following subdirectories:
backend - backend web application.
common - files common to all applications.
console - console application.
environments - environment configs.
frontend - frontend web application.
Root directory contains a set of files.
.gitignore contains a list of directories ignored by git version
system. If you need something never get to your source code
repository, add it there.
composer.json - Composer config described in Configuring Composer.
init - initialization script described in Configuration and
environments.
init.bat - same for Windows.
LICENSE.md - license info. Put your project license there.
Especially when opensourcing.
README.md - basic info about installing template. Consider replacing
it with information about your project and its installation.
requirements.php - Yii requirements checker.
yii - console application bootstrap.
yii.bat - same for Windows.
There are three applications in advanced template: frontend, backend
and console. Frontend is typically what is presented to end user, the
project itself. Backend is admin panel, analytics and such
functionality. Console is typically used for cron jobs and low-level
server management. Also it's used during application deployment and
handles migrations and assets.
There's also a common directory that contains files used by more than
one application. For example, User model.
Frontend and backend are both web applications and both contain the
web directory. That's the webroot you should point your web server to.
Each application has its own namespace and alias corresponding to its
name. Same applies to the common directory.
The css, js for frontend or backend application is generally stored inside the corresponsing web/ folder.
I use follow strukture:
config
environments
runtime
vendor
my-modules
frontend
backend
other vendor
bum
uuu
www-frontend
assets
index.php
www-backend
assets
index.php
www-other-end
assets
index.php
All install/update by composer.In config directory set specific configuration. Can setup unlimeted www.
I am new to both Symfony and Angular and I am trying figure out how the pieces will fit together. I want to user Symfony for my back end and web api. I want to use Angular for the front end desktop like experiences.
I am not sure how the folder structure should be. Do I put my angular javascript/typescript files in folders in the root of the Symfony project and utilize their folder structure. Or do i have two bundles in my src folder. One for the back end/website. Another for the front end? Or should the back end be serving twig templates with angular components inserted?
***** Edit *****
#Tobias Xy Correct me if I'm wrong but that would be creating bundle in the src folder and keeping the files in a resources folders in it correct?
Then i see the following at the bottom:
Frontend-Based Applications
Recently, frontend technologies like AngularJS have become pretty
popular for developing frontend web applications that talk to an API.
If you are developing an application like this, you should use the
tools that are recommended by the technology, such as Bower and
GruntJS. You should develop your frontend application separately from
your Symfony backend (even separating the repositories if you want).
So they are saying make two seperate projects and not use a bundle for the front end?
If so how do you host this? On two different sites?
Symfony is a backend framework, so there is no point in adding a bundle containing only frontend files (css, javascript, etc).
See also Web Assets (Symfony Best Practices)
They say there:
Store your assets in the web/ directory.
Update 23.03.2016
Cerad wrote in the comments: "client-side angularjs and reactjs apps have their own build system just like Symfony does".
This is actually a different topic, but the article I linked to above also says something about that:
Recently, frontend technologies like AngularJS have become pretty popular for developing frontend web applications that talk to an API.
If you are developing an application like this, you should use the tools that are recommended by the technology, such as Bower and GruntJS. You should develop your frontend application separately from your Symfony backend (even separating the repositories if you want).
For Angular 2 there might be differences in the front end build system, but the structure should be similar to the one I use for Angular 1.x.
The folder structure I use to place my front end assets in something we could describe as a three level process. Let's just enumerate the three levels here:
Level 1 - The src/AppBundle/Resources/Private folder
Inside this folder, I place any front end assets that need any kind of processing, like transpile, autoprefix, uglify, etc. This will be the case for most JS, SCSS, LESS or HTML files of your choice. You can define the folder structure you prefer.
Level 2 - The src/AppBundle/Resources/Public folder
This will be the folder that'll contain all assets after processing AND any other asset that didn't need processing, usually images, fonts, etc. This will be the folder structure that will literally be copied over to the web/bundles/app folder in Level 3.
Note: This level is indeed redundant and can be skipped with caution. In my case, I kept it to avoid 'accidents' with the way Symfony wants to install assets by default, which will replace your web/bundles/app folder with the contents of this one. This will be the case if you use any other bundle that installs assets this way, like FOSJsRoutingBundle for example.
Level 3 - The web/bundles/app folder
This is the final public destination of your assets, and the path where you'll reference them in your code. It is just a copy of the src/AppBundle/Resources/Public folder from level 2.
Build system
You will need a front end build system to transpile your files and copy them to the respective folders in level 2 and 3. In my case for Angular 1.x I used Gulp with Node. This means you'll have gulpfile.js file, package.json file and node_modules folder in your project. I didn't care, it worked fine. Just remember to not add node_modules folder to your repo.
In production
Unless you really need to rebuild in production for some reason, you can skip level 1, level 2 and gulp related folders and files like node_modules, gulpfile.js, etc.
You could create the client side as the root document and the server side as an alias location, but careful to not overwrite the alias.
Or you could change the host.
Example 1:
[client] www.example.com/<client_root_dir>
[server] www.example.com/api/<server_root_dir>
or Example 2:
[client] www.example.com/<client_root_dir>
[server] api.example.com/<server_root_dir>
I want to create a single Laravel installation that comprises the core functionality of the websites - for example content CRUD functions.
Then on top of this in separate folder on the server for each website have the public folder, css, images etc as well as overriding controllers, models and routes that can be used for specific features per site.
I have achieved the same previously using FuelPHP but have not been able to see where this would be setup in Laravel.
The kind of server folder structure I was anticipating is as below:
/Laravel Core Installation
/app
/vendor
storage
etc
/The first website
public
app (in here would be controllers and models that extend the controllers and models from the Laravel Core Installation folder)
config
etc
/The second website
public
app (in here would be controllers and models that extend the controllers and models from the Laravel Core Installation folder)
config
etc
What you are referring to is called multi tenancy.
Multitenancy refers to a software architecture in which a single instance of a software runs on a server and serves multiple tenants.
http://en.wikipedia.org/wiki/Multitenancy
There are several packages that assist with multi tenancy for Laravel, based on your needs. Some work with seperate database table prefixing, others with completely seperated databases and files.
Some of those packages:
Tenanti
AuraEQ
Hyn *
* Disclaimer; I wrote the last package from this list.
This is the situation i am currently having issues with:
I have 1 webserver, this webserver must run 2 different websites, those websites are all written in symfony2 and share the same Bundle that i wrote.
Currently this bundle is placed in the src/ folder and loaded in the AppKernel.
Right now i am using the apps approach where i have 2 seperate app folders created in 1 folder called apps ( http://jolicode.com/blog/multiple-applications-with-symfony2 )
However right now my situation changed, i have this 1 webserver with 2 different websites but i also have a second webserver which must also be able to have multiple apps.
Both servers should not share the same configuration files which is having me a lot of difficulties with deploying.
I also want to prevent that i have to deploy unused bundles to a server.
I hope i explained everything as clear as possible, it is not easy to make a description.
As I read, the app folder contains all config or not files related to the app ( doctrine, Kernel, cache, logs, etc). Routing, Services or other files related to how works an specific bundle should be within that bundle in my opinion.
I think there is not a standard or good way to do this because symfony right know has the workflow one app - one project. Any structure which separates bundle config and app con
fig is valid if don't mix both kinds
Can somebody explain in brief the use of assets folder in yii framework. I am new to yii framework
Many newcomers ask: "What do we do with the assets folder?", and the answer is "Mostly nothing".
It's important that the directory be writable by the webserver user so that Yii can publish the resources there when needed.
When a project has multiple versions (production, testing, development, etc.) do not copy the assets/ folders from one area to another; allow Yii to deploy them automatically in each area.
Do not manually edit any file under assets/ - if you have a real need to make a change, find the publishing module, edit the source, delete the subfolder under assets/, and let Yii re-publish the updated files.
Do not reference names under the assets/ folder directly (say, to get at some other module's assets). If you need to use that
Do not add the contents of the assets/ folder to any source-code control system; these files have master source in other places.
It is safe to delete everything under assets/. Yii will re-publish the assets if they are not found under assets/.
Additional info
Yii makes assets accessible by Web clients, so the goal of copying assets to a Web-accessible directory is fulfilled and returns the corresponding URL for accessing them.
Read it from http://www.yiiframework.com/doc/api/1.1/CAssetManager