Software Development Web Development

My symfony command line cheat sheet

I can never remember all the symfony commands. So I will add them here one at a time as I need them to create a cheat sheet.

Cache – clearing the cache explained

Clear all the caches

php bin/console cache:pool:clear cache.global_clearer


Software Development Web Development

Symfony 5+ using the command line and listing commands

Symfony has useful command line commands. But what are the available commands and how do you get a list?

To get started type the following in the command line in your projects main/root folder. This is the directory that contains the directories src,assets, bin, public, node_modules etc.
php bin/console -help
That command will output the following

bin console help
Output of php bin/console -help command

This shows we can use bin/console list and a few more. Now try the command and see what the list shows.

Available commands:
  about                                      Displays information about the current project
  help                                       Displays help for a command
  list                                       Lists commands
  assets:install                             Installs bundles web assets under a public directory
  cache:clear                                Clears the cache
  cache:pool:clear                           Clears cache pools
  cache:pool:delete                          Deletes an item from a cache pool
  cache:pool:list                            List available cache pools
  cache:pool:prune                           Prunes cache pools
  cache:warmup                               Warms up an empty cache
  config:dump-reference                      Dumps the default configuration for an extension
  dbal:run-sql                               Executes arbitrary SQL directly from the command line.
  debug:autowiring                           Lists classes/interfaces you can use for autowiring
  debug:config                               Dumps the current configuration for an extension
  debug:container                            Displays current services for an application
  debug:event-dispatcher                     Displays configured listeners for an application
  debug:form                                 Displays form type information
  debug:router                               Displays current routes for an application
  debug:translation                          Displays translation messages information
  debug:twig                                 Shows a list of twig functions, filters, globals and tests
  debug:validator                            Displays validation constraints for classes
  doctrine:cache:clear-collection-region     Clear a second-level cache collection region
  doctrine:cache:clear-entity-region         Clear a second-level cache entity region
  doctrine:cache:clear-metadata              Clears all metadata cache for an entity manager
  doctrine:cache:clear-query                 Clears all query cache for an entity manager
  doctrine:cache:clear-query-region          Clear a second-level cache query region
  doctrine:cache:clear-result                Clears result cache for an entity manager
  doctrine:database:create                   Creates the configured database
  doctrine:database:drop                     Drops the configured database
  doctrine:database:import                   Import SQL file(s) directly to Database.
  doctrine:ensure-production-settings        Verify that Doctrine is properly configured for a production environment
  doctrine:fixtures:load                     Load data fixtures to your database
  doctrine:mapping:convert                   [orm:convert:mapping] Convert mapping information between supported formats
  doctrine:mapping:import                    Imports mapping information from an existing database
  doctrine:migrations:current                [current] Outputs the current version
  doctrine:migrations:diff                   [diff] Generate a migration by comparing your current database to your mapping information.
  doctrine:migrations:dump-schema            [dump-schema] Dump the schema for your database to a migration.
  doctrine:migrations:execute                [execute] Execute one or more migration versions up or down manually.
  doctrine:migrations:generate               [generate] Generate a blank migration class.
  doctrine:migrations:latest                 [latest] Outputs the latest version
  doctrine:migrations:list                   [list-migrations] Display a list of all available migrations and their status.
  doctrine:migrations:migrate                [migrate] Execute a migration to a specified version or the latest available version.
  doctrine:migrations:rollup                 [rollup] Rollup migrations by deleting all tracked versions and insert the one version that exists.
  doctrine:migrations:status                 [status] View the status of a set of migrations.
  doctrine:migrations:sync-metadata-storage  [sync-metadata-storage] Ensures that the metadata storage is at the latest version.
  doctrine:migrations:up-to-date             [up-to-date] Tells you if your schema is up-to-date.
  doctrine:migrations:version                [version] Manually add and delete migration versions from the version table.
  doctrine:query:dql                         Executes arbitrary DQL directly from the command line
  doctrine:query:sql                         Executes arbitrary SQL directly from the command line.
  doctrine:schema:create                     Executes (or dumps) the SQL needed to generate the database schema
  doctrine:schema:drop                       Executes (or dumps) the SQL needed to drop the current database schema
  doctrine:schema:update                     Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata
  doctrine:schema:validate                   Validate the mapping files
  fos:js-routing:debug                       Displays currently exposed routes for an application
  fos:js-routing:dump                        Dumps exposed routes to the filesystem
  lint:container                             Ensures that arguments injected into services match type declarations
  lint:twig                                  Lints a template and outputs encountered errors
  lint:xliff                                 Lints a XLIFF file and outputs encountered errors
  lint:yaml                                  Lints a file and outputs encountered errors
  make:auth                                  Creates a Guard authenticator of different flavors
  make:command                               Creates a new console command class
  make:controller                            Creates a new controller class
  make:crud                                  Creates CRUD for Doctrine entity class
  make:docker:database                       Adds a database container to your docker-compose.yaml file
  make:entity                                Creates or updates a Doctrine entity class, and optionally an API Platform resource
  make:fixtures                              Creates a new class to load Doctrine fixtures
  make:form                                  Creates a new form class
  make:message                               Creates a new message and handler
  make:messenger-middleware                  Creates a new messenger middleware
  make:migration                             Creates a new migration based on database changes
  make:registration-form                     Creates a new registration form system
  make:reset-password                        Create controller, entity, and repositories for use with symfonycasts/reset-password-bundle
  make:serializer:encoder                    Creates a new serializer encoder class
  make:serializer:normalizer                 Creates a new serializer normalizer class
  make:subscriber                            Creates a new event subscriber class
  make:table-meta                            Creates classes with table data
  make:test                                  [make:unit-test|make:functional-test] Creates a new test class
  make:twig-extension                        Creates a new Twig extension class
  make:user                                  Creates a new security user class
  make:validator                             Creates a new validator and constraint class
  make:voter                                 Creates a new security voter class
  reset-password:remove-expired              Remove expired reset password requests from persistence.
  router:match                               Helps debug routes by simulating a path info match
  secrets:decrypt-to-local                   Decrypts all secrets and stores them in the local vault
  secrets:encrypt-from-local                 Encrypts all local secrets to the vault
  secrets:generate-keys                      Generates new encryption keys
  secrets:list                               Lists all secrets
  secrets:remove                             Removes a secret from the vault
  secrets:set                                Sets a secret in the vault security
  security:encode-password                   Encodes a password
  server:dump                                Starts a dump server that collects and displays dumps in a single place
  server:log                                 Starts a log server that displays logs in real time
  translation:update                         Updates the translation file

Wow that is a lot of commands. Enter the list command in your terminal to get a better view.

mr rodgers how it is done meme
And that is how it is done!!!
Web Development

How fix doctrine error : You are missing a “cli-config.php” or “config/cli-config.php” file in your project, which is required to get the Doctrine Console working.

So while following this guide in the documentation to try to reverse engineer my database with Doctrine, I got the following 100% absolutely nonsensical error

Importing mapping information from "default" entity manager
 writing src/Entity/AffiliateArticleViews.php
 writing src/Entity/AffiliateJoinCounts.php
 writing src/Entity/AffiliateRegistration.php
 writing src/Entity/BlogMedia.php
 writing src/Entity/CommentReplyConclusionOptions.php
 writing src/Entity/CommentReplyReportReasons.php
 writing src/Entity/DoctrineMigrationVersions.php
 writing src/Entity/FavoredImages.phP

In DebugClassLoader.php line 346:

Warning: include(/var/www/sogi/sogizmo/vendor/composer/../../src/Entity/FavoredImages.php): failed to
open stream: No such file or directory

To someone who doesn’t work on the Symfony core that might as well say “boasdfkajsdfiioaysdfiuasdfiouasdfiouasdiofu”

So I had to research this issue.

Doing Research!!!

Ok so I found this link with a little more info and I ran the following line of code.

php vendor/bin/doctrine orm:generate-entities --help

Which barfed out these lines of more mysteries to be solved.

You are missing a "cli-config.php" or "config/cli-config.php" file in your project, which is required to get the Doctrine Console working. You can use the following sample as a template:

<?php use Doctrine\ORM\Tools\Console\ConsoleRunner; // replace with file to your own project bootstrap require_once 'bootstrap.php'; // replace with mechanism to retrieve EntityManager in your app $entityManager = GetEntityManager(); return ConsoleRunner::createHelperSet($entityManager); </code

Leaving me wondering WTF is this even talking about like…

Who comes up with this?

Google and dig as I may I only found one Stack answer that explained how to created the mess of files required. Sure would be nice if that was in the Doctrine docs…

But I kept digging, trying, failing… and it turns out that the first error I got means…. wait for it…. MY USER DOCTRINE IS RUNNING AS CAN’T WRITE TO THE DIRECTORY.  Now wouldn’t it make much more sense to give that as an error message?


So I changed the Entity directory permissions to 775 since my server www-data was already a member of a group which was the group owner of that directory. And the first command finally worked like it had before. Some how somewhere along the way I set permissions on the Entity and all folders to 755.

The error messages were no help. I just randomly decided to try creating another test folder with 775 and ran the first command again. I accidentally guessed what the problem was from a nonsensical error message. Desperation wins in the problem solving game. LOL

That wasn’t the end though. When I tried to run the second command I got another nonsensical error about my Entity classes already exist. I was like I know the first command created them WTF. Kept googling and searching and scratching my head. Then I remembered I created the test folder so I deleted it and BOOM BANG POW. Everything was working fine.

i m stupid meme
Im is stupid
Web Development

WordPress : Update failed: The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.

So you got this error when trying to update one of your plugins or upload an image or something else?

I was confused by this message right after creating a new wordpress website and then migrating my content.

I did a bad, bad no, no while updating and lost the entire site, so I had to start again from a bakcup. Yes I have lost this entire site. Thank god for backups. You’d be amazed how quickly you learn when you have no other choice. LOL. I highly suggest jetpack backups. The cheapest jetpack package is all I have and it is AMAZING.

The migration seemed to work fine. All my articles appeared. All my images appeared. I felt I had achieved a great success.

borat great success meme
I had a great success. NOT!!!

Then I tried to write an article and add an image. I got a failed to upload image message. The odd thing is I could go to old articles and still upload images.

WTF is going on here
So why doesn’t this work?

I thought that was weird. Then I got a notice in my dashboard that a plugin needed updating. I tried to update it and got the error that lead you here.

I was lazy and ignored it a few days, thought it was just the plugin. Then another plugin needed updating. When I tried to update it I got the error again.

Update failed: The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.

I’ve done a lot of server admin work so I knew it was a simple permission issue. The only problem I had no idea what directories/folders needed permission changes and what they needed to be.

So I did a little research.

Doing Research!!!

And the reason the name of this article is so long? Because nothing I typed matched a damn thing and I figured someone would be having this issue soon. LOL

You will need to login to your server either with SSH or many hosting companies now have a way to open a terminal right in your user interface.

First you will need to update the user permissions with usermod. After this your files owner and group will be something like www-data that is what my server (Nginx) was named. Here is a link to how to find out what yours is named.

sudo usermod -aG www-data $USER

The above line adds your current user to your servers group (Apache/Nginx). More on that here on Stackexchange if you look for the above command in the answers.

If you need to know where your wordpress is installed type the following using find command again.

find -name wordpress

That command will output something like /var/www/html/…/…/…/wordpress  It finds anything with the name wordpress.

Next set the permissions on the files under your wordpress directory. Mine was located at /var/www/html/ so I used.

find /var/www/html/ -type f -exec chmod 664 {} \;

This uses the find Linux command and exec with chmod command. Basically this line of code is using the find command to find all the files (f) in the directories in or below /var/www/html/ and it applies chmod to them with permissions of 664. This means the owner and group have the read/write permissions but other users can only read. No one has the execute permissions not even root because this could cause security issues.

Next you need to change the directory permissions so that wordpress plugins can write to them and images can be uploaded etc. This will use the find command too, but slightly different syntax. This time use a d to find the directories in or below /var/www/html/ like so. Again your path may differ

find /var/www/html/ -type d -exec chmod 775 {} \;

I think I originally tried something more restrictive than 775 and something failed. Like something during a plugin update needs to have that permission level to work. 775 means the owner and groups can read/write and execute. I’ll be working on this again soon and see if I can get the permissions tighter and update this article.

That should make your wordpress work. Your site may be located in a directory different from /var/www/html/ you will need to look in your Server (nginx/apache) settings for the root directory or use the find -name wordpress command shown. That is where the permissions need changing. This all depends on who installed your wordpress, but I believe the above is default.

More about using exec with find

cool stuff meme
Cool stuff man.

How to configure a fake domain name on your localhost on linux aka virtualhosts

Often when testing a web project locally you will use something like http://localhost:9000. Unless you are using Docker and dockerizing your app. What if you want to run multiple apps or multiple versions of one app at the same time and instead of going to localhost:9000, localhost:9001 etc. etc. you want to go to https://yourappname and https://yourapp-name2 …

Well on linux you edit the Hosts file and create a loopback to localhost or whatever IP you want. I mostly leave it with the localhost loopback though to prevent myself from blocking access to other websites on accident.

Here is an example of my hosts file, you can see I have made quite a few changes. This file is usually located at /etc/hosts there is no document type just “hosts” is the name. localhost sogi-test sogizmo
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Now this way I can type http://sogizmo and my app opens on localhost. I can open another tab and type http://sogi-test. This is also handy for testing that your app works correctly with SSL/https. I’ll cover how to do that in another article later.

Note if you add a .com to the end of your app names you block your access to the real app from your device only. That is, your PC uses the hosts file to lookup hosts before hitting your router which hits your ISP servers, which does a reverse lookup. If you have in your hosts file and try to access that from your computer that you made changes to the hosts file on, it will take you to your local copy not the .com website so remember not to add the .com

I still find the old fashioned way easier for now. Plus I haven’t fully embraced Docker other than running things my app needs without installing them. I am slowly moving more towards dockerizing everything.

There is still more to do to get the app to work correctly on your system though. You will also need to configure your local server to serve pages from your apps local root directory.

I use Nginx so this is as easy as a few lines of code and a few minor changes. The files are located in /etc/nginx/sites-available. I wont cover the configuration because it is different for each app, however the location is always the same.  Here is a link about configuring Nginx. Here is the official documentation for Nginx.

Basically inside the Nginx configuration you want to set the name of the server to the same as the name you listed in the “hosts”file for me it is sogizmo.

Like so :

server_name sogizmo;

Then you need to tell Nginx where your server root is on my system for my app it is

root /var/www/sogizmo/public;

So basically that is it. You add your desired site name in the hosts file with an ip such as Then you create your Nginx or Apache configuration and set your server to match the name you added in the hosts file. Then you set the root directory for your app. There are also other things you will need to set in the configuration based on the tech stack your app uses.

Random Software Development

How to go back multiple directories in a linux terminal command line

Often when I am using the command line in a terminal on Linux I need to go back more than one directory. Usually you use the command

cd ..

Which takes you back one level in a directory. For example if you are in /var/www/http and you type cd .. you will be in directory /var/www/.

But what if you are super deep in the directory and need to get back to www directory. Say you are in /var/www/http/website/public and you want to get back to /var/www/http you can either type:
cd .. ( inside /var/www/http/website/ )
cd .. (inside /var/www/http/ now )

But you can type the following and get all the way back to the /www/http/ directory in one line
cd ../..
That line will take you back two directories. If you need to go further back just continue adding ../..

Software Development Web Development

How to fix Github git keeps asking for password with ssh keys

This was a super annoying issue I have had for years. I never looked into it because I was lazy.

I setup my ssh keys like you probably did and I kept getting prompted for my password.

I kept entering it for years because the github docs are not that great and fail to mention how to fully setup the keys properly(maybe changed by now). I kept wondering why it was asking me to enter my password even with the ssh keys.

Well a few days ago August 13th 2021, github switched from allowing password ssh git push/pull to not allowing it and forcing you to use something like ssh keys. I went to push to my github repo and was told I had to use ssh keys blah blah…

I was like

spock WTF
Wait. WTF?

I thought I had setup the ssh-keys. But, what had happened was I had used the HTTPS method to pull the repo. So my git config was set to the HTTPS endpoint not the SSH endpoint. It had been a long time ago. I thought I had setup the keys, and I did. What I failed to do was switch the git remote value in the git config.

are you kidding me
Freaking seriously

Basically if you pulled a repo via https then you need to switch your git configuration to use the ssh url. I won’t make this article longer writing how to do that, here is a great, short article that explains it

You also need to know the ssh repo value which you can find in the repository under clone like this

github clone
remote repo name

I have not tried the newer GitHub CLI. I will eventually read about it and try it and update my repos to use it. I did write about using github ssh deploy keys here though.  And about using multiple deploy ssh keys here.