Magento 2: Add Local & External CSS and JS file

This article shows different ways to add CSS and JS files in Magento 2. Add CSS & JS from Layout XML file In this example, we are adding JS and CSS via layout file in your custom module. app/code/YourCompany/YourModule/ view/frontend/layout/frontName_controllerName_actionName.xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <!– local CSS file –> <css src="YourCompany_YourModule::css/custom.css"/> <!– local … Read more

PHP: Debug Backtrace with Example

This article shows how we can use the debug_backtrace() PHP function to generate a backtrace. This function returns an array of associative arrays. It includes the current function name, file name, class name, line number, etc. where the debug backtrace function was called. Syntax debug_backtrace(int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT, int $limit = 0): array Parameters $options … Read more

Git: Fix differences created by line endings in files

This article explains the issue created by line endings in code in different OS versions and also provides solutions to fix the issue by normalizing the line-endings in files. Introduction Files created/edited on Windows OS and Mac/Linux OS can have different line endings. Suppose, a developer (Dev1) created a file in Windows OS and pushed … Read more

Git: Create & Apply Patch using format-patch

Previously, I had written an article to create and apply patches using the git diff and git apply commands. In this article, we will look into alternative git commands to create and apply git patches. Those commands are git format-patch (to create patch) and git am (to apply patch). Check commits in your branches Checkout … Read more

Git: Diff, Create & Apply Patch

This article shows how you can get differences in the git branch, file, or commits and create and apply git patches. > git branch master * test > git checkout test > git log –oneline -n 5 04d3d11 (HEAD -> test) Update README 39fdf70 Update hello file 32547fa Add hello file 87ea803 (origin/master, origin/HEAD, master) … Read more

Git: Pull remote branch from someone else’s Fork

There can be a scenario where you would need to continue working on the work done by someone else on your team. In such a case, you can pull your team member’s fork branch and continue working on whatever is done in that team member’s branch. You can add your code changed and push it … Read more

Git: Reset to older commit / Undo changes & Push

This article shows how you can reset your git state to any older/previous commit and then push to your origin repository. Reset to older commit git reset –hard <commit-hash> Example: git reset –hard 39fdf70 Force push to origin repository git push origin –force # OR git push –force If you only want to reset in … Read more