Symfony 2 - switching from app_dev to app - php

i didnt understand how assets:install works..
When i run php app/console assets:install web it copy these bundles.
Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
Installing assets for Sensio\Bundle\DistributionBundle into web/bundles/sensiodistribution
I want to copy my project to app.php, the project is in /src/Dproc/..bundles..
How should i do that?

Switching to the prod environment:
php app/console cache:clear --env=prod

Related

How do I run symfony console?

Everywhere I look in the Symfony documentation for Symfony 4.2, it says that to clear the cache, I run:
php bin/console cache:clear
However, this bin/console is a relative path. I can't find bin/console anywhere. I've done a find on my composer vendor directory. Nothing.
Where is bin/console?
I'm running php 7.2.
Symfony 4.x structures in like this (From CoderSkills)
If you don't have the same after your installation, remove your project folder and create a new ones by running composer create-project symfony/website-skeleton myNewProject
Here is a guide to start a new Symfony project

Can't run php bin/console in symfony

I'm new on symfony, after following instruction to install it, it said i have to run:
bin/console server:run
i type it on my symfony instalation folder. but i got error:
Could not open input file: bin/console
and then i'm searching the answer in here and it told me to run app/console
bin/console server:run
but it just got the same problem. is it i miss some bin folder here or something? since i can't see bin folder or app folder on my project root folder. here's my project folder structure:
You obviously cloned a Git repo, which does not contain all Symfony framework components.
You have to create symfony project through
symfony installer http://symfony.com/doc/current/setup.html
or
with composer composer create-project symfony/framework-standard-edition my_project_name.

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

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