Super globals and constants in twig

As about language.php file I said above, do you suggest any better way to handle language?

The Symfony2 Translation Component.

If you have decided to work with this framework, keep in mind that it implements a lot of great stuff to build a strong web app’.

@scoolnico Thanks.
Someone please help for this or this. I am stuck. I am not sure if this is a bug, may be I should still change something else too?

PS.
@swader Do you have any idea?

@nimasdj don’t use global constants and your problems are solved.

1 Like

Ok. I don’t use global constants for language any more. But that css background image problem has nothing to do with constants and I don’t use constants either. May you please kindly help for that css issue as I am stuck?
@swader

@Jeff_Mott Do you have any idea for problem above?

You’re taking an entirely wrong approach to the whole matter and it’s confusing to understand, sorry. You shouldn’t be developing applications in such a way, and you should never ever try to “secure” an app with .htaccess files.

1 Like

Do you mran I have to install app directly in main website folder, public_html, that /src/,/app/ will be in upper level folder outside of public, instead of installing it in a folder like http://www.mysite.com/symfony that other folders would be still in public folder?
Anyway if i want to do so, why css images are broken?
@swader

Ditto everything swader has said.

Global constants are the kind of code you want to move away from. Symfony is built so that everything is local, dependency injected, and decoupled.

If you’re trying to do language translation, then read up on how Symfony does translations.

For your CSS problem, only the web/ folder is supposed to be in the web server’s document root. Don’t treat the project root as if it were the web root.

And more generally, try to start using these tools in the way they were designed to be used. You keep running into problems because you keep trying to do weird and unusual things.

Ok. I’d go with your and swader’s advicrs. But assuming symfony web root is http://www.example.com/symfony and other /app/, /src/ folders should be moved two folder levels upper rather one level, to place them out of public. So just changing kernel and loader path in app.php is enough to call them from two folder levels upper rather than one? Or any other changes are still needed?

No I wouldn’t do that either. I would use Apache’s Alias directive.

  Alias /symfony /path/to/symfony/web
  <Directory "/path/to/symfony/web">
    AllowOverride All
    Allow from All
  </Directory>

@jeff_mott What does it do? Does it redirect http://www.example.com/app and http://www.example.com/src to http://www.example.com/symfony? right?
Why not just disallowing access to them with .htaccess?
If I want to re-distribute my app to others I have to tell them to edit this apache with correct path? Isn’t it an easier way? isn’t it better to move app.php to root and secure other folders with htaccess?
even if I want to move other folders two levels upper to place them outside of public, there should be a write_to config to let it know where to install assets, but it seems there is a bug that assets:install does not recognize write_to cofig for ‘bundles’ and only dumping assets will be created in write_to location. I reported this bug to them but I was completely ignored. Only this current structure works properly OR it should be installed certainly in main root folder directly that other folders would be outside of public.
It seems I am just wasting my time with symfony as its assets is very buggy and has problems when you want either to move app.php to root or move other folders two levels upper, or which way do you go to make it more user-friendly for your end-users if you want to distribute your app?

@Jeff_Mott going with your and @swader’s advice, if my symfony /web/ folder is http://www.example.com/symfony/ then how to secure other folders like: http://www.example.com/src/ and http://www.example.com/app ? I did not understand, please clarify.

@swader If I should not secure http://www.example.com/app and http://www.example.com/src with htaccess then how should I secure them to have its /web/ folder as redirect http://www.example.com/symfony? As I said its assetic is buggy if changing its current structure. what do you advice?

@Jeff_Mott
Sorry, did not understand how to use it. assuming all /web/, /app/ and /src/ are in /symfony/ folder, where should I place that htaccess? in /symfony/ folder itself? and it should be like this?

Alias /symfony /symfony/web
<Directory "/symfony/web">
 AllowOverride All
 Allow from All
</Directory>

I got 500 error for this. please advice.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.