Hikmadh Commerce| Ecommerce Development Consulting | Magento Development and Consulting Service

Symlinks in Magento 2

What is Symlink?

 

  • A symlink or a Symbolic Link is simply enough a shortcut to another file. It is a file that points to another file.

  • I have attached the below two images for identifying symlinks.

  • Symlinks are generated in the pub static folder of Magento 2 in developer mode.

Symlinks are generated in the pub static folder of Magento 2 in developer mode.

Common issue faced by Developer when working with knockout Js

In the development stage, when you are working with Js, knockout js and knockout template, the developer faces below issues

  • The changes in knockout js and knockout templates are not affecting on frontend when page load.
  • The developer has to delete the pub static folder or run static content deploy command every time when changes in js and knockout template file.

If you are facing this kind of issue in development, please verify the below steps.

  • Is the developer mode enabled?
  • Is symlink is generated in pub static folder or not?
  • When doing development, open the inspect element in the browser and in the network tab and select the Disable cache checkbox

A Detailed Discussion on Magento 2 Modes

One of the significant differences between Magento 1 and Magento 2 is the introduction of Magento Modes. These modes have different configurations of the Magento platform which affect the store’s performance and operations.

In Magento 1, there was a single state for both production and development, but in Magento 2, there are three primary Magento 2 modes:

 

  1. Default Mode
  2. Developer Mode
  3. Production Mode
    1. There is also another mode known as

“Maintenance Mode,”

     but it operates very differently by preventing access to the system.

Default Mode

As the name describes, the Default mode is how Magento 2 works, if no other mode is specified. It lets you deploy Magento on a single server without changing any settings and configurations. However, the Default mode is not optimized for production.

 

      1. The Default mode has the following key features:
      1. Errors and Exceptions are never shown to the user. They are logged to var/reports directory at the server.
      2. Symlinks to the static view files are published to the pub/static.
      3. The Default mode hides custom X-Magento-* HTTP request and response headers
      4. This mode is not optimized for the production environment because the static view files are first materialized and then cached.

Developer Mode

This mode is recommended for developers and is the recommended mode for the development. You should set the Magento 2 Developer mode when you need to customize and extend the platform’s functionalities. This mode is slower on the front end and the website admin.

      1. Some other features of the Developer mode include:
      2. Uncaught exceptions and errors displayed in the web browser.
      3. Enhanced debugging
      4. Verbose system logging.
      5. The exception is thrown in the web browser when an event subscriber cannot be invoked.
      6. The exception appears in the error handler rather than being logged.
      7. Automatic code compilation.

Production Mode

When your store is ready to go and has been deployed to a production server, you should set the Magento 2 in production mode. After that, you should also deploy the static view files to the Magento 2 pub/static directory because this improves the performance of the store.

      1. In production mode
    1. Static view files are not materialized. They are only served from the cache.
    2. Errors are never displayed to the user. Instead, they are logged to the filesystem.

Setting Magento Modes

To change or set the Magento mode, you can use the following CLI command in your SSH Terminal:


php bin/magento deploy:mode:set {mode} [-s|--skip-compilation]

In the above command, {mode} is the required field. It can be either production or developer. –skip-compilation is the optional parameter used to skip code compilation when you set the Magento 2 to production mode.


After changing the mode, you might want to clean the cache as well by running the following command:


php bin/magento cache:clean

See the Current Mode

The easiest way of checking what mode is active right now, run the following CLI command:


php bin/magento deploy:mode:show

A message, similar to the following line will be displayed:


Current application mode: production

Final Thoughts

I hope now you will have a better understanding of the Magento 2 modes, as well as how to change the mode and see which mode your Magento 2 store is using. Using the different modes for Magento 2 offers new ways for development and enhance the performance and functionality of the platform. Cloudways always look for the new and improved ways of Magento server that help Magento merchants and community to grow and fulfill the complete Magento 2 hosting requirements. So please let us know if you have any questions or feedback!