Symfony did not create model - php

I am going through symfony book and trying to do jobeet project(I use propel).. so here what book says
The ORM also generates PHP classes that map table records to objects:
$ php symfony propel:build --model
The propel:build --model task generates PHP files in the lib/model/ directory that
can be used to interact with the database.
I run that command and when i go to lib/ direcotry , there is no model folder :/

You have to write:
$ php symfony propel:build-model

Have you tried this?
sudo ./symfony project:permissions
./symfony project:cc
./symfony propel:build-all-load // this will write to your db as well
otherwise please consider pasting the output of propel:build-model and your symphony version :)

Related

creating bundle in symfony in terminal

i want to create a bundle in my symfony project via
php bin/console generate:bundle
but it errors me in the terminal:
[Symfony\Component\Config\Exception\FileLoaderLoadException] The file
"../../src/AppBundle" does not exist (in:
C:\wamp64\www\exp\app/config) in
C:\wamp64\www\exp\app/config\services.yml (which is being imported
from "C:\wam p64\www\exp\app/config\config.yml").
[Symfony\Component\Config\Exception\FileLocatorFileNotFoundException]
The file "../../src/AppBundle" does not exist (in:
C:\wamp64\www\exp\app/config).
You might have deleted AppBundle from src folder (or test folder) manually which is the major reason for getting this error.
Browse app\config\config.yml , app\AppKernel.php and app\config\routing.yml and remove the referring to AppBundle.
Once done Please clear the cache and re-run the project.

Run yii commands from shell script

I am trying to make a script which automaticly loads a project from a git repository. I run exec() from a php file with name of the shell script as an argument. The script looks something like this:
git pull
php yii migrate
The git command works well, but the yii command is totally ignored. I'm doing this from the root of the directory of the yii site, so it should work, but it doesn't.
How can I fix this?
if you are using Yii version 1.x, you have to run your command from inside protected directory
cd protected
php yiic.php migrate
First of all, if you want to run console application in Yii2, just use
yii <route> [--option1=value1 --option2=value2 ... argument1 argument2 ...]
Second: yii migrate is the defined console command to upgrade a database to its latest structure. So it probably does its work, but not that you want to.
Try to rename your console command.
Reference links to read:
Guide: console commands
Guide: migrations (part with yii migrate).

Translation catalog generation with Symfony2 for main app

I used the following command to generate the catalogs of my different Bundles and it worked well.
php app/console translation:update --dump-messages --force fr ProjectBlogBundle
But how should I do to translate the view that we can find on /app/Resources/views/* ?
Thanks,
If you check the command code, it looks like it's not possible: the bundle name is required and must be provided.
However, you can check this out.
Even though you can't automatically extract/update translation segments from those views, the runtime translation should work, provided that you use the same translation domain.
Even though this question is rather dated, I figured I might add this just for anybody else stumbling across this:
It seems that the desired functionality has been added in the meantime (Symfony 2.8+).
If you run the command like this:
$ app/console translation:update --help
Usage:
translation:update [options] [--] <locale> [<bundle>]
Arguments:
locale The locale
bundle The bundle name or directory where to load the messages, defaults to app/Resources folder
It seems the bundle name has become optionale and the command will default to app/Resources
I had the same problem, and the #Jan's answer helped me. So there is an example.
cd app/
php ./console console translation:update --dump-messages --force fr .
As . is a directory (the current directory), the translator will try to load the subdirectory /Resources, so here it will try to load app/Resources/.

How to create a migration in YII?

I have just started with YII and I am trying to create a new migration. I am using Xampp and it is located in the d drive of my system.
The command that I am trying to use is:
D:\xampp\php> d:\xampp\htdocs\yii\framework\yiic migrate create create_project_table
When I run the above command nothing happens, neither do I get an error message nor there is any error.
I did manage to successfully create a shell by using
D:\xampp\php> d:\xampp\htdocs\yii\framework\yiic shell d:\xampp\htdocs\trackstar\index.php
I tried to search for any solution for the migration issue but they all seem to be linux based. Please let me know what I am missing here. Thanks for your help.
I managed to create the migration sucessfully. Turns out that I needed to use the yiic located in the protected folder of my application instead of the yiic located in framework folder of yii. The command that I used is
D:\xampp\php>D:\xampp\htdocs\trackstar\protected\yiic migrate create create_project_table
I have found that you need a forward slash in my version.
yii migrate/create <migration_name>
First you need to go to protect folder on your Yii project
Then run the comamnd:
php yiic migrate create create_new_table_name_table

Symfony 2 - How to delete a bundle?

So my question is how to delete bundle I created?
You create bundles with this console command:
php app/console generate:bundle --namespace=Test/BlogBundle --format=yml
And thats awsome but what if I need to delete this bundle?
Is there a console command to delete a bundle I dont need any more?
I know that when you create new bundle from console, you:
1. create /src/Test/BlogBundle directory
2. change /app/config/routing.yml file to include routes
3. include your new bundle in /app/Resources/App.Kernel.php
4. I think there is something changed in /app/cache/...
Now what would be correct way of deleting a bundle completely?
Its joust that using console these bundles are generated "magically" so I dont know what did this command changed in folder structure and files?
It is basically the process you have outlined, only in somewhat different order.
delete /src/Test/BlogBundle directory
change /app/config/routing.yml file to remove the bundle routes
remove your new bundle from /app/AppKernel.php
clear cache (either by deleting cache/{$env} or console cache:clear)
If this wasn't installed using a dependency manager - that should be all.
I know I am late to answer this but Symfony has instructions on how to delete the bundle. This is how I delete. You can use the same instructions for other bundles you created and want to remove now.
To delete a bundle in Symfony 3 (and higher) :
Method 1 :
go to composer.json, search & delete the bundle.
run composer update ( it will automatically remove the bundle and clear the cache)
Method 2 :
run composer remove alias/to/your/bundle
f.e : composer remove nesbot/carbon
That's all.

Categories