projet symfony dont display css and js and pictures - php

I created one project in symfony 2 I send it to my company but the project not working properly no fils css, no file js no pictures.
I'need my my laptop it works correctly.
So i connected remotly to my company
I excuted this command
php app/console assetic:dump
but I have this problem
There are no commands defined in the "assetic" namespace.
Did you mean this?
assets
I don't know why I have this problem with this command. But
php app/console assets:install it works correctly
Thanks stack overflow

In the documentation is written that be used with:
php app/console assetic:dump --env=prod --no-debug
maybe the directory seperator like \ and no /
https://symfony.com/doc/2.8/assetic/asset_management.html#dumping-asset-files-in-the-prod-environment

this command belongs to this bundle
https://github.com/symfony/assetic-bundle
I think above bundle is not installed.
check your composer.json or vendor folder.

Related

Symfony 2 doesn't generate web/bundle/framework structure

I have a huge problem with Symfony. I installed Symfony 2.7.5 from command line:
$ symfony new my_project
But the main problem is that all project was generated correctly with the exception of directory: /web/bundle
So I have in this folder two empty files (not catalogues!) with 0 KB size: framework and sensiodistribution. That means all Symfony error pages haven't any css style and look ugly.
Screens:
My local folder:
and
Error page:
What should I do?
Command:
$ app/console assets:install
populated this catalogue and it was the solution of the problem.

Symfony2.7.1 fresh installation. Failed to load resource

Symfony2 developers:
Recently, I am planning to get familiar with Symfony2, using it as api project. Current version is v2.7.1.
I already have apache installed as my local environment. So the installation root directory is:
//localhost/symfony
So I followed official guide to install it. Everything looks fine after installation. But when I view the page in development environment (app_dev.php).
//localhost/symfony/web/app_dev.php
Page content display as expected, but not styled. Then I open console and find some 404 response as follows:
Failed to load resource
//localhost/symfony/web/bundles/framework/css/structure.css
//localhost/symfony/web/bundles/framework/css/body.css
//localhost/symfony/web/bundles/framework/css/exception.css
//localhost/symfony/web/app_dev.php
//localhost/symfony/web/bundles/framework/css/structure.css
//localhost/symfony/web/bundles/framework/css/body.css
//localhost/symfony/web/bundles/framework/css/exception.css
I looked into project/web/bundles directory, found nothing inside but two empty file.
framework and sensiodistribution.
Fresh installation without any config change. I got this problem. Could you guys give some explanation why it occurs. Otherwise I didn't get the full package?
Do I miss those files inside project/web/bundles?
If the case in which i missed those file. So could you send me an archive file on current version 2.7.1?
You must run the command app/console assets:install to generate symlinks (or files) in /web/bundles
If these files exists then you probably have problem with URL Rewriting check your .htaccess or configure your host. You can also use command php app/console server:start and check there if it works
You can run composer install to install all necessary bundles and libraries and probably composer.json has defined postinstall commands.
If you use assetic then you can try to run php app/console assetic:dump more on http://symfony.com/doc/current/cookbook/assetic/asset_management.html
In Symfony 2.6 you have new asset manager read more on http://symfony.com/blog/new-in-symfony-2-6-smarter-assets-install-command
php app/console assets:install or php app/console assets:install --symlink
for Symfony 3.x the directory changed from app to bin so commands are:
php bin/console assets:install or php bin/console assets:install --symlink
Since I landed here from a Symfony 3 search this might be useful for Symfony 3 users having the same problem
Run php bin/console assets:install at the project root

PHP app\console wont work trying to create bundle for Symfony2

I have installed Symfony2 on a iis 7 server with PHP 5.3.21 and everything works ok ( the php, the symphony demo page ).
I try to create my own helloWorld, as the tutorial says :
php app/console generate:bundle
I go Start->Run->CMD and put that line of code and it gives me back this :
could not open input file : app/console
and before anyone asks i am in the project directory when i perform this command
I put the PHP directory to the System PATH but the problem persists.
Update: I ended up getting on a screen sharing program with #reza and discovered he had accidentally set his PATH variable to D:\php\wamp\bin\php\php5.3.10\php.exe rather than D:\php\wamp\bin\php\php5.3.10. Fixing this solved the problem.
Check this: I can't create bundle in symfony2
For newer versions of Symfony (2.4.x or newer) use this method on windows to resolve the problem:
Go to project directory e.g. d:/xampp/symfony2-project/ and open composer.json and place this under requires array "symfony/console": "2.4.*#dev". And save the file.
Open command-line and cd to project's directory.
Use this command to let download and install the dependencies: php path/to/composer.phar install. Remember you should be in your project's directory and path/to/composer.phar is the actual path to your composer.phar file.
Now you are all done, just use php bin/console generate:bundle --namespace=Test/PrintBundle --format=yml to test bundle system works.
If you are creating Symfony 2.5 project using command prompt then console file is not storing the app folder but it storing in the bin folder so you need to use bin folder instead of app folder (CODE is : php bin/console generate:bundle).

Steps for going live - Symfony2

I've been working on my website for some time now and I am now ready to push this brand new project to live.
I have already already read this link on Symfony2 with regards to what should be done, but I still think it is missing some details. For example, it talks nothing about some of the commands that I run to get the site to work on live.
Currently this is what I would like to do to get this to work on live:
php composer.phar install --no-dev --optimize-autoloader --no-scripts
rm -rf app/cache/*
php app/console assetic:dump --env=prod --no-debug
php app/console assets:install web --symlink --env=prod
Is there anything else that needs to be done, for example, I don't want live to be able to execute my fixtures, nor do I want any users to be able to go to www.mysite.com/app_dev.php
Check out How to deploy a Symfony2 application.
Refer to link above. The typical steps taken while deploying a Symfony2 application include:
Upload your modified code to the live server;
Update your vendor dependencies (typically done via Composer, and may be done before uploading);
Running database migrations or similar tasks to update any changed data structures;
Clearing (and perhaps more importantly, warming up) your cache.
Common Post-Deployment Tasks
Configure your app/config/parameters.yml file
Update your vendors
$ php composer.phar install --no-dev --optimize-autoloader
Clear your Symfony cache
$ php app/console cache:clear --env=prod --no-debug
Dump your Assetic assets
$ php app/console assetic:dump --env=prod --no-debug
Other things!
There may be lots of other things that you need to do, depending on your setup:
Running any database migrations
Clearing your APC cache
Running assets:install (taken care of already in composer.phar install)
Add/edit CRON jobs
Pushing assets to a CDN
...
take a look at capifony (https://github.com/everzet/capifony). Unfortunately the Website (http://capifony.org) is currently down..
The best solution to me is to have your project in a versionning system like git or svn without the vendors dir of course ...
This way, your simply have to do :
1) git clone your project into the prod dir
2) php composer.phar install to install your vendors
2b) create the mysql user with correct login and password according to your parameters.yml
3) php app/console doctrine:database:create to create your database with the credentials you set up in mysql
4) php app/console doctrine:schema:update --force to perform the database tables creation
5) testing the project :)
If you are not using a versionning system just upload your project to your server with an ftp software without the vendors directory ( it will be feeded by step 2) then perform 3rd , 4th and 5th steps !
you now should be able to reach you project through you domain url .

problems with symfony2 images (403 forbidden)

I uploaded symfony2 project to servergrove.com and after this created assets using
php app/console assets:install --symlink web
and also
php app/console assetic:dump --env=prod --no-debug
After these steps I can't access images in the web/bundles folder, I get a "403 forbidden" error.
The URL to my site is http://myserjtankian.com.preview-sg111.servergrove.com/
You may fix that using this command line (without --symlink web arg) :
php app/console assets:install
This will install assets as hard copies.
Hope it's helpful
Best regard

Categories