Blogs of php-2

We are a web development and outsourcing agency based in Kochi, India.

FedEx Tracking API Integration with PHP

FedEx Tracking API Integration with PHP

FedEx is an American courier delivery services company. By using FedEx Tracking API, we can get real-time tracking information for FedEx Express, FedEx Ground, FedEx SmartPost, FedEx Home Delivery, FedEx Express Freight, FedEx Freight, and FedEx Custom Critical shipments.   FedEx Web Services Environments FedEx API has 2 environments. Testing and Production.  The FedEx Web Services Testing Environment is a functional, full-runtime environment ideal for testing your web services solutions. Although good for confirming functionality, the Testing Environment should not be used for stress testing. It is recommended that developers test to ensure that their code operates as desire...

How to fix the Insecure Direct Object Reference Vulnerability in Laravel

Insecure Direct Object References occur when an application provides direct access to objects based on user-supplied input. As a result of this vulnerability, attackers can bypass authorization and access resources in the system directly, for example, database records or files. Consider, User A uploaded a private photo at http://www.mysite/private/photo/5 and User B uploaded a photo at http://www.mysite/private/photo/6  (you should never use incremental ID's in the URL in the first place, use some random keys. This is just an example to show the concept.) Now User B shouldn't be allowed to view the photo of User A at http://www.mysite/private/photo/5, but many develope...

How to upload, download, remove files in AWS server using SFTP from Laravel

Amazon Web Services (AWS) provides a reliable and scalable platform for hosting web applications and storing data. One of the ways to transfer files to and from an AWS server is through the Secure File Transfer Protocol (SFTP). In this guide, we'll show you how to use Laravel to upload, download, and remove files in an AWS server using SFTP. To get started, you'll need to set up an SFTP server on your AWS instance and install the necessary packages in your Laravel application. Once you've configured your SFTP connection, you can use Laravel's built-in Filesystem API to interact with your AWS server. Below are the steps needed to Upload the file to the AWS serve

Simple explanation of abstract classes and why we would use them

Lets consider an example. We are creating 2 classes for employees in an office. There are 2 kinds of employees, fulltime and contract employees. Both type of employees have some common methods and properties like, name, monthly salary etc.class EmployeeFulltime {   public $fistName  = '';   public $lastName  = '';   public $annualPay = 0;      public function __construct($employee)   {    $this->firstName = $employee['firstName'];    $this->lastName  = $employee['lastName'];    $this->annualPay = $employee['annualPay'];   }   public function getFullName()   {    return $this->firstName . " " . $this->lastName;   }   public function g...

Regular expressions in PHP

PHP has three sets of functions that allow you to work with regular expressions. Programmer s does not use these powerful functions often as it seems to be difficult to create patterns. Also it is not easy to find a basic and simple regular expression tutorial in a single webpage .  So I would like to give a try on this to collect the info and make it easy to learn and interesting. Also I will include some very useful reg-expressions in the end of this post. About regular expressions A regular expression is a pattern that can match various strings. Regular expressions started as a feature of Unix shell. They were made to make string operations easier. It’s really useful in programming with PHP as they help to reduce a lot of codes. As a simple example we can say t...

Estimating Shipping Rate on Product Details Page in Magento

To display the shipping rates on the product view page in Magento 2, you can use a custom block and template. Just follow these simple steps to make it happen: Create a Custom Module: If you don't have a custom module yet, it's a great idea to create one following the best practices for module creation in Magento 2. Create a Block Class: In your custom module, let's create a block class to handle the super cool logic for obtaining shipping rates! <?php // File: app/code/YourVen...

Setting the ‘continue shopping’ URL to last product’s category page in magento

Here is a code snippet for setting the ‘Continue Shopping’ location to the category listing page of the last product added to the cart. Open the template/checkout/cart.phtml file in your active theme. Place the following code in the foreach loop

(ie. after this line of code)

< ?php foreach($this->getItems() as $_item): ?>

that generates the products list in the cart.

< ?php
$_categories = $_item->getProduct()->getCategoryIds();
$_category = Mage::getModel(‘catalog/category’)->load($_categories[0]);
$url = $this->getUrl($_category->getUrlPath());
Mage::getSingleton(‘checkout/session’)->setContinueShoppingUrl($url);

?>

You are done!

Are the product images not appearing in Magento after installation or migration?

This is a common issue that many Magento 2 users face, and there are several possible causes and solutions for it. Here are some of the most common ones: The product images are not in the correct directory or have incorrect permissions.  You should make sure that your product images are located under pub/media/catalog/product/ in your Magento 2 installation, and that they have the correct permissions (755 for directories and 644 for files).  The product images are not resized or regenerated properly. It would help if you run the command bin/magento catalog:images: resize in your Magento 2 root directory to resize and regenerate the product images ...

Why is the new theme not appearing in Magento 2 after installation?

You did a successful Magento installation, the base theme is showing up and you are all good to go. Then you uploaded your theme and updated it from the Magento backend. Still, it’s not showing up. This is a problem that might eat up some of your time. Usually, a straightforward solution will fix it.

Once you’ve created the theme in the right folder, just run these commands: 

php magento cache:clear

php magento setup:upgrade 

php magento setup:di:compile and 

php magento setup:static-content:deploy --theme {vendorName}/myTheme2

That should do it!

2hats Logic HelpBot