Category Archive Hosting Article

Cheap Drupal 8.0.4 Hosting Recommendation

How to Manually Clearing Your Magento Cache

Sometimes when moving, migrating or changing domain names for your Magento installation you may run in to issues with the cache redirecting users to the old domain.

What Are the Benefits of Clearing the Cache?

Cache (/kæʃ/ kash, or /ˈkeɪʃ/ kaysh) is a hardware or software component that stores data so that future requests for that data can be served faster.

So it’s all about storing the requested data for easier access later. Both the browser and the server make a cache for faster performance.

There are two caching techniques: full-page caching and object (fragment) caching. The names speak for themselves: you can both cache the entire page or only separate objects in it, like heavy images.

You can’t even imagine how much your website speed impacts your traffic and conversions.

If you’re using cache correctly, then your cached website will perform faster, and with higher speed come high conversion rates.

Let’s see what are the two types of cache that you should know about.

Types of Web Caching

There are two main types of website caching.

1. Browser caching

The browser cache is a temporary storage space in the hard drive of the user’s computer. The storage contains files like HTML, JavaScript, CSS, images and all kinds of media.

Once a user visits your website, the browser saves some of the data to display it later without reaching out to your server again. Thus, browser cache speeds up your website for returning visitors.

Now you must wonder what happens with cache when you update your website. Do the visitors keep seeing the older version? The answer is no; not if you’re doing it right.

To avoid this situation, most websites use ETag and Expire Tag.

The first one — ETag — is a token that compares the cached version of the website with the one on the actual server. When they vary, the browser requests the updated version of the website.

The second one — Expire Tag — is there to set up the period after which the cached version is removed from the browser.

Website owners/administrators manage this tag and pick the average time they are having between updates.

2. Server caching

Server caching speeds up websites for anyone, not just the returning visitors. This is how it works: when browsers request a webpage, the server takes time to process those requests.

After the first request (from any user) is fulfilled, the server “remembers” it and next time it delivers the same data to anyone faster.

Lower server loads are one of the biggest benefits of caching: millions of users can open the website at the same time, and it won’t blow up.

On top of the hosting servers, there’s a caching system for DNS (domain name system).

See, DNS is often called the phonebook of the Internet. It connects web addresses like 10web.io to hosting servers’ IP addresses like 28.56.8.252.

The system operates through tons of servers called nameservers holding records about these addresses. Caching nameservers (also called DNS cache) store information about DNS queries for as long as the administrator decides. That period is called TTL (time to live) and is essential when you are changing your domain name or hosting.

Caching & CDN

The physical distance between a user and a server they request used to be a real issue for website load speed for a long time. Content delivery (distribution) network — CDN is the solution.

These networks consist of several servers located in different part of the world. They cache the commonly requested files of a web page (static content) and when a user enters a query, the nearest server responds with the ready-to-display content.

The servers are smart enough to recognize the device type, cookie settings, and other information about the user to cache and display the exact required pages.

CDN is also useful to deliver dynamic content — which is unique and not cached — faster.

Why should you clear the cache?

  • To get the newest version of a site. One common reason why you might want to clear your cache is if a website or application has made updates but they don’t show up on your browser because of the old cached website version.
  • To be more secure. If you’re sharing a computer with other people, clearing website cache will help you protect your privacy.
  • To improve performance. Even though caching is meant to improve website performance, if you don’t clear them a while, a lot of data accumulates and has the opposite effect.
  • To fix browser errors. If you see certain sites lagging or errors popping up, better clear the cache just to be sure.

This can make it difficult to login to the administration section to clear the cache, to make the site work. Often you will see that your site gets stuck in a redirect loop that won’t complete. In this quick and easy guide, we will show you how to clear your Magento Cache.

Steps to take

There are three simple steps that can be taken to solve this issue.

  1. Login to your FTP account. This can be done through your FTP Client or Webshell.
  2. Find the Magento installation located in your domain
  3. Remove the content of the following two folder’s
    • /var/cache
    • /var/session

As always we strongly recommend you take a backup of these files before removing them, even though they are only cache files.

How to Clear Cache Programmatically

In case of development, a developer or a request from merchant, he/she needs to clear / flush cache programmically. So today we will show you how to Clear Cache Programmically. Implement these lines of codes in Helper:

<?php
use Magento\Framework\App\PageCache\Version;
use Magento\Framework\App\Cache\TypeListInterface;
use Magento\Framework\App\Cache\Frontend\Pool;
protected $cacheTypeList;
protected $cacheFrontendPool;
 
public function __construct(
    TypeListInterface $cacheTypeList, 
    Pool $cacheFrontendPool
){
    
    $this->cacheTypeList = $cacheTypeList;
    $this->cacheFrontendPool = $cacheFrontendPool;
 
}
 
public function flushCache(Version $subject)
{
  $_types = [
            'config',
            'layout',
            'block_html',
            'collections',
            'reflection',
            'db_ddl',
            'eav',
            'config_integration',
            'config_integration_api',
            'full_page',
            'translate',
            'config_webservice'
            ];
 
    foreach ($_types as $type) {
        $this->cacheTypeList->cleanType($type);
    }
    foreach ($this->cacheFrontendPool as $cacheFrontend) {
        $cacheFrontend->getBackend()->clean();
    }
}

Now call flushCache() function in a controller or model.

Cheap Drupal 8.0.5 Hosting Recommendation

How to Transfer Site from Wix to WordPress

Wix and WordPress are two world-popular web design platforms, each of which is the leader in its niche. The systems are used to complete an extensive variety of tasks, targeting diverse user categories. They utilize diverse approaches to the process of website development, which is mainly explained by the distinctive features of both platforms.

While Wix is the all-in-one websites builder, WordPress is a renowned Content Management System. The platforms imply various degrees of web design proficiency and they differ in integrated characteristics used for website development.

Situations when you start realizing that your Wix website lacks functionality are quite frequent as it is impossible to tell in advance how thriving your business will be. Whether you have an online store or a business website built with Wix, you may feel the need to use more advanced features and tools for its further development. If this is just the situation you face, you may consider an opportunity to switch from Wix to WordPress.

When adopting the decision to transfer your website from Wix to WordPress, you should realize that the process is not quite simple. This is especially true for beginners, who may lack web design skills and expertise to handle a variety of technical nuances. The migration process also implies content and domain transfer, traffic redirection to new hosting, preservation of the search engine ranking of your project and lots of other issues. If you feel that it will be difficult for you to take care of all these nuances on your own, have a look at the tips this gude offers to simplify the transition process for you.

1. Moving Website from Wix to WordPress – Is it Worth It?

Here is the list of widespread reasons that can make you think about switching from Wix to WordPress:

  • If you run a Wix-based business website, a web store, a portfolio or any other web project, you may realize that your company/business keeps developing steadily. This may require deeper integrated functionality that goes far beyond those options the website builder offers. WordPress, in its turn, may provide those tools and features you currently need.
  • You might need unique design customization options or integrated functions Wix cannot offer as a website builder. In this escase, WordPress proves to be a more feature-laden platform due to its extensive plugin integration and template customization opportunities.
  • Finally, you may need a fully-responsive website, no matter what specialization it has. WordPress has more to offer in this respect, while Wix allows creating mobile-ready projects that may lack responsive nature.

Whatever reasons you have to move your website from Wix to WordPress, you will definitely be satisfied with the result. The system has much to offer, although, it also requires coding proficiency to get the most out of its performance.

2. Wix versus WordPress – What Is the Difference?

Wix and WordPress are two quite different systems, which offer deep functionality and website customizability. The difference between the systems, however, is quite striking, which is mainly explained by the features and implication of each platform.

First and foremost, Wix is a popular SaaS website builder, which makes it possible to create different types of one-of-a-kind websites. WordPress, is a CMS, which requires preliminary download and installation to be further used for website creation. Secondly, Wix comes with an integrated collection of high quality mobile-ready templates that are completely customizable and niche-specific.WordPress, in its turn, implies the need to pick a suitable design out there – the choice is fantastic yet you have to be very attentive not to choose a low quality theme.

wix editor

The next distinction between the platforms is about their integration options. Wix grants access to its App Marker, where everyone can choose from multiple free and paid widgets for further website integration. WordPress stands out from the crowd due to its advanced integrations, offering hundreds of free and paid high end plugins to boost the performance of your web project. It takes time and knowledge to integrate the selected plugin into your website, though, and you also have to be twice attentive when making your choice because of the increased website security threat.

WordPress Themes

Finally, one of the main distinctions between Wix and WordPress is hosting choice. While the website builder comes with integrated hosting/domain name options, the CMS triggers the need to pick a third-party hosting provider, a suitable package and a domain name. This, correspondingly, requires extra budget investment.

Thus, the differences between Wix and WordPress are quite obvious. These distinctions give each platform its unique functionality and special features, which also affect user choice.

3. How to Switch from Wix to WordPress – The Ultimate Guide

The essentials are provided in this Wix to WordPress guide you can browse and memorize to complete the task in the best way possible:

  1. Select a proper hosting. While Wix offers integrated hosting, WordPress allows selecting your own hosting provider. This is the very first step you should start with. Explore the available and the most popular hosts, select a suitable plan and learn the terms and specifications it offers.
  2. Transfer domain name. If your Wix website comes with a registered domain name, the next step will be to transfer it to the selected hosting provider. The terms and cost of the migration process will depend upon the host and the plan you will go for.
  3. Install WordPress. on the selected hosting and learn the basics of using the system. This doesn’t take much time and effort as the setup process is quick and simple. The system comes with an understandable tutorial, which offers step-by-step guidelines on how to cope with its installation with ease. Mind, however, that there may be certain technical nuances you shouldn’t overlook, if you don’t wish to put your website performance at risk.
  4. Copy the Design. It’s impossible to copy the entire Wix design to WordPress automatically as there are too many nuances here. To get a similar website design, you have to manually create it yourself. With this purpose, you can either select and customize a ready-made WordPress template or hire a freelance web designer, who will complete the task for you.
  5. Export Wix website data to WordPress. Just like with design transfer, you’ll have to export your Wix data and import it into WordPress manually. Copy the texts and create pages in your WordPress website to further import the posts there.
  6. Import Images. WordPress doesn’t automatically import images from your Wix account. This means that you’ll have to do that manually once again. To do that, you need to install WordPress Import External Images plugin. As soon as the plugin is activated, access the “Media >> Import Images” section and complete the task.
  7. Check out and Set up Permalinks. If you don’t wish to lose your Wix website traffic, take your time to check out the final WordPress URL structure to make sure it is correct. Fortunately, due to powerful plugins WordPress is a SEO-friendly CMS and it will make it possible for you to set up and customize the structure of all your website links. Take your time to check, if you have properly transferred your title and description meta tags for each website page.
  8. Customize your website. Having done that, it is high time to explore WordPress and use its tool set to customize your newly-transferred website.

There is also one important issue you should be aware of. Don’t hurry to deactivate your Wix website or close your account. It may come in handy to you, if something goes wrong with website migration process. You will easily do that, when you are completely done with the migration process – just make sure your WordPress website functions well.

4. How to Transfer Own Domain Name from Wix to WordPress

When it comes to Wix-to-WordPress website migration, it is important to preserve your domain anime and to move it along with your website to the new platform. This contributes to the preservation of your project search engine ranking, traffic, brand recognizability and its further promotion.

To properly move your Wix domain name to WordPress, you should follow a standard algorithm of actions. Wix provides detailed steps in its customer support section and it’s up to you to analyze them and to pick the most suitable approach. Actually, you can either transfer the active domain name from Wix to WordPress or connect it to the CMS.

There is also an opportunity to transfer the expired Wix domain to WordPress, if you wish to preserve its current SEO positions. When dealing with your domain migration, you should not forget about email transfer/connection, which goes along with the domain. That’s the surefire way to receive all the important email notifications throughout the migration process. Fortunately, there are multiple resources that can help you find out how to transfer a domain name from Wix to WordPress correctly.

5. Professional Wix to WordPress Migration Services

Whatever the reasons to move from Wix to WordPress are, there are lots of issues to complete to make the process a success. The entire procedure of moving from one platform to another should not be difficult and complex, if you are aware of all the technical nuances and characteristics of both services. It’s great, if you are a niche specialist, but what if you aren’t? In this case, you can choose one of the available solutions.

The first solution provides an opportunity to select one of specialized website migration programs. These tools are not altogether safe as a chance that your website will come with serious mistakes after the migration process are also quite high. What’s more, website migration programs are not cheap, which means that you automatically invest into a service that does not guarantee decent result. Is there anything you can do about that? Fortunately, yes.

Bottom Line

Wix websites are undoubtedly full-featured, but WordPress is the CMS that really excels at functionality and can bring your website performance to the top notch level. Upon the completion of the website transfer process, don’t hurry to publish it. Prior to doing that, make sure all the plugins are installed properly and function correctly. The same is about the templates and content presentation.

You should also check, whether all the redirects from old to new website pages are activated and test the website one more time. Another must-have task is to check the responsive nature of your WordPress website to see how well it is displayed on mobile devices.

Cheap Classic ASP Hosting Recommendation

How To Secure Your WordPress Website – Step By Step Guide

When you’re in charge of WordPress websites for several clients, it’s hard to ever relax. Problems seem to come out of nowhere, and clients will email, text, and call in a panic because their site has slowed down or crashed. Plus, if one client’s site goes down, you know that there could be trouble with all the other ones as well. Being dedicated to your job and having clients spread across different time zones means you never get a break from the worry.

There’s no surefire way to ensure a website never, ever has a problem. However, relying on dependable WordPress-focused services, like your host and theme provider, can solve and prevent many common issues, including hacks.

If your WordPress site has ever been hacked – or even if you’ve just imagined it when going over all the possible outcomes – you know the panic that’s bound to set in. Simply knowing a security breach is possible is enough to get you on track to creating a safer website that’s monitored by a reliable host. In this article, we’ll go over how to harden your WordPress website and arm it with the best security possible.

There are a number of reasons why your WordPress site may get hacked – and there are several ways to strengthen your site, too. Let’s go over the main security vulnerabilities that every agency, developer, and freelancer should know about, plus, how to protect your site from falling prey to them.

Always Use the Latest Version of WordPress

Every time WordPress releases a new version, you should update your website as soon as possible. WordPress versions often have security patches to fix problems with the previous version. If you don’t update, you could leave your site vulnerable.

By always having the latest version of WordPress, you close security gaps that hackers can potentially get through. Your best option is to set up automatic updates so they run without you having to do it manually. And remember that every time you update your site, you should have a backup of your site saved. Any quality host will automatically update your site to the latest version of WordPress so that you don’t have to stay on top of it.

Use the Strongest Passwords Possible

If you don’t create a secure enough website, it’s easy for hackers to access your WordPress admin panel – and once they do that, they can do pretty much anything they want. Hackers use automated tools to run through numerous potential passwords until they hit on the right one. They can then log in to your WordPress admin account and have full control.

Having a weak password is one of the biggest website vulnerabilities, but it’s also the one that’s easiest for you to remedy. In addition to setting a secure password for your WordPress admin account – and changing it regularly – make sure that every website-related service is protected by a strong and unique password, like your FTP and host logins.

Here are a few tips for setting strong passwords:

  • Don’t use a version of your name, username, brand name, or website name.
  • Don’t use a dictionary word, whether it’s in English or another language.
  • Never create a short password – it should be around eight characters, minimum.
  • Don’t use just letters or just numbers – your password should combine letters, numbers, and symbols.

There are security plugins such as Wordfence (also available as a standalone Login Security plugin) you can use that will force all users to create strong passwords, and sometimes this service comes standard with hosting plans. Also, if you add two-factor authentication to your website, it’ll be even harder for hackers to get in and create their own account. Furthermore, if you haven’t already, set a schedule for regular password updating, like once every 30, 60, or 90 days.

Set a Limit on Login Attempts

WordPress default is to let users attempt to log in a limitless number of times. However, this leaves your site vulnerable to hackers who attempt to find your password by trying numerous combinations. You can use a dedicated plugin such as Wordfence, linked above, to set a limit on login attempts, but your web application firewall (more on that in a bit) may come standard with this feature.

Limit Access to Your Site

The larger your team, the harder it is to limit who has access to your site. However, the fewer people, the better, because you lower the risk for accidental or purposeful security breaches. Look through your list of admin accounts (go to Users in the Dashboard sidebar) to see if there are any that are no longer part of the team, don’t need access to WordPress or should have less access to your site. Also, note any users that you don’t recognize.

Before removing a user you don’t recognize, check with your account holders to see if they updated their account details – it’s possible a user is an actual admin, but they’ve made a change you don’t recognize. At this point, also clean up your user list to remove anyone who is no longer part of your website and/or shouldn’t have access. Click the checkbox next to any user you want to remove, then change the Bulk Actions dropdown to Delete. Or, to remove a single user, click the Delete link under their username.

Set a Logout Timer for Idle Users

If you have a lot of people who have access to your site, consider using a dedicated plugin that will automatically log them out when they’re idle. If the user walks away from their computer while they’re still logged in to your site, anyone can make changes to your WordPress account. A plugin, such as the free Inactive Logout, will let you set the duration to decide how long a user can be idle before they’re auto-logged out. You can also write a message that will pop up on the screen right before the user is logged out – that way, if they’re still in front of their computer, they can opt to stay logged in.

Reinforce Your Site With Server-Side Protection

When you can have protection on the server-side of your site, hackers will have an even tougher time breaking in. By adding an extra layer of protection to your wp-admin, you protect your login screen, WordPress admin area, and files. The best way to do this is by using HTTPS SSL, which is an encrypted connection, to protect your wp-admin. Check with your host to see if they offer this level of security.

Use a Web Application Firewall

One of the best ways to keep your site secure is by using a web application firewall (WAF). Essentially, a WAF will keep malicious traffic away from your site. There are two options:

  • DNS-level firewall: This type of firewall will send traffic through its own cloud proxy servers. The only traffic that will make its way all the way to your site will be quality, non-malicious traffic.
  • Application-level firewall: When you use a plugin to serve as a WAF, the traffic will reach your server, but the plugin will check it out before loading scripts.

While an application-level firewall is better than nothing, a DNS-level firewall is the safer option of the two. Popular plugins like Wordfence, services like Cloudflare, and secure hosts like ASPHostPortal offer this.

Only Install Up-To-Date, Reliable Plugins and Themes

If you have out of date or nulled plugins or themes, your WordPress website is vulnerable to a hack. “Nulled” refers to premium plugins and themes that should be paid for (when purchased from the right source) but instead are offered for free on another site. These elements are meant to collect information or, worse, harm your site.

Never use a plugin or theme from a source you don’t trust. Select yours from the WordPress library or make sure to read plenty of reviews if you go with an outside source. Furthermore, any plugins you choose should be tested and compatible with your WordPress version.

The reason why plugins and themes have to be updated is that those updates include security features and patches. If you don’t have the latest version, you don’t have the latest security measures. Stay updated by always using the latest versions of reputable plugins and themes. If you choose the right hosting provider, they’ll run these updates for you.

Get Rid of Unused Installations

If you have deactivated plugins and themes that you won’t be needing, delete them. The same goes for unnecessary files, WordPress installations, and databases – get rid of them. The more data that’s sitting in WordPress, the more vulnerable your site is, especially when it comes to old WordPress installations that won’t be up to date.

Delete Unwanted Files

You need to discover any files that don’t belong there, and then remove them. To do this, you may need to install a security plugin, like the ones below. Popular options are Wordfence (again!), Defender, and MalCare. These types of plugins can scan your site and alert you to anything that doesn’t belong.

Security plugins image

However, note that a quality web host will do this for you automatically, which means you won’t have to worry about installing a plugin, scanning regularly, or removing problematic files. And if you feel that your site needs a manual scan right now, you can contact your host to handle that for you, too.

Run Regular Backups and Scans

Backup your WordPress site regularly (once a day or more), and make sure to include the database, media files, and plugin and theme files in each backup. Also, run malware and file integrity scan regularly to locate any malicious files that may be on your server. There are several WordPress security plugins you can use to automate this process. However, note that scans don’t actually remove malware – they just let you know it’s present. You’ll still need to get rid of the malware yourself (or have your host handle it).

You should regularly scan for malware, spyware and viruses on your computer, too. No matter how secure your website is, if your computer is unsafe – for example, if there’s a keylogger on it – your website is at risk.

Monitor Changes to Your Files

Any time an attack occurs, there’s some trace that it leaves behind – there may be evidence of the attack in the logs or in files, for example. You should be monitoring your files all the time, and there should be alerts set up so that you know whenever a change is made. That way, if a change occurs that you didn’t know about in advance, you can quickly assess if it’s due to a security breach or not. Some of the plugins mentioned above, such as Defender, can take care of this for you.

Regularly Clean Your Database

When you clean out your database, you get rid of extra, unnecessary data that your site’s accumulated over time, like spam and trash comments, settings for themes you no longer use, etc. The less useless data there is in your database, the faster your site will run. Plus, if you received an alert from your security plugin or provider that your database has been hacked, this step is a necessary one. There are several plugins to choose from in the WordPress directory: WP Optimize is the most popular dedicated option, or you can consider WP-Sweep, or Advanced Database Cleaner. Alternatively, you can work with a host who handles regular database cleanups for you.

Choose a Secure Web Host

When you’re partnered with an unreliable and insecure hosting company, you face a number of problems, including the inability to scale, too much server downtime, and single points of failure. You should be able to scale your site up when traffic surges without worrying that it’s going to crash, go down, or become more vulnerable to security breaches. Here’s another consideration: the best hosting isolates each website so that one compromised site doesn’t affect any others.

If you settle for an inexpensive and low-quality hosting package, you’ll be sharing a server with hundreds of other customers. As a result, your site will slow down. Also, all of those other sites pose security risks to your site ­– the more sites that are crammed on a server, the more insecurities there are. Furthermore, a “budget” host probably won’t monitor your site closely or know if there’s been an attack.

Most hosting companies offer some sort of security service, but wherever their role stops, yours begins – and if you have no clue how to manage or secure a website, yours could be left highly vulnerable. Work with a host that will offer an array of security features and around-the-clock monitoring and management. Your host should also:

  • Be open to answering any of your questions about security, including explanations of the features they offer and their processes.
  • Offer the most recent stable version of software.
  • Regularly backup your website, while also offering reliable processes for recovery should something go wrong.

Two standard security measures that every site should have are configuring a firewall and adding SSL for extra security. You can use plugins for both of these must-haves, but to keep your site lean, it’s best if you find a host that includes these features in their standard plan.

Here are two more important considerations when choosing a web host:

  • Don’t use a shared server. You should never choose a host that will put your site on a shared server. When you’re on a shared server, that server is hosting your site along with many others. If one site is compromised, yours is at risk, too.
  • Use SFTP encryption. Your web host should offer SFTP encryption, which means that your data and password are encrypted when you connect to your server. Even if there’s a hacker present, they won’t be able to see your password, because it will be concealed when transported between your computer and your website.

Set up Recurring Security Measures

By adding a security plugin to your WordPress site, you’ll be notified of suspicious activity as soon as it occurs. For example, if someone attempts an unauthorized login or adds a file, you can get a notification. The plugin should provide a warning that clearly communicates what the issue is so that you know the next steps to take.

Alternatively, you can work with a security service provider that will monitor your site and fix problems that occur. This is a costly option, though, but security shouldn’t be an option for most site owners ­– you need your WordPress site to be safe. Quality WordPress hosting should have 24/7 security monitoring built-in so that you don’t have to hire yet another service provider just to keep your site functioning.

How to Prioritize WordPress Security With Your Web Host

It’s best to always partner with providers that use top-notch security services. For example, Patchman is a server-level solution that detects and fixes vulnerabilities and malware. It does it all while running behind the scenes – customers don’t have to install or configure it, or even keep an eye on it for maintenance. When Patchman catches a security fix in a new release, it backports the fix to apply it to all earlier versions.

Here’s another example: Human Presence’s behavior analysis engine detects and eliminates 99% of malicious bot spam. Website visitors can’t see that it’s working, but it continues to protect analytics, comments, forms and reviews, and it also stops content and data from being scraped from your site.

When you choose web hosting from ASPHostPortal, security services come standard. For example, Cloudflare’s enterprise security functionality is a good way of securing your WordPress site, but it usually costs upwards of $200 per month. With next-generation hosting, you get this out-of-the-box.

These other security features are highly important, too. With many hosting packages, you’d have to purchase these security benefits separately – now, you can have them included in your standard package:

  • Advanced firewall rules.
  • Advanced managed rule set.
  • Automated malware patching.
  • Automated vulnerability patching.
  • Comment and form spam protection.
  • Enterprise DDoS mitigation.
  • Human presence bot detection.
  • Intelligent threat detection.
  • OWASP core rule sets.
  • Rate limiting.
  • Reputation-based threat protection.

Find a Web Host You Trust

Relying on secure WordPress hosting is a must for agencies, developers, freelancers, and any website owner who needs their site up-and-running without hiccups. Full-service hosting means you can rely on your provider to watch your website closely, know as soon as there’s an issue and fix it, all without your involvement. Here are just a few of the features to look for in a secure web host:

  • HTTPS
  • Latest PHP
  • Disabled directory browsing
  • Hardened database security
  • Encryption
  • Scales to demand (which also avoids unnecessary costs)
  • Site isolation and container security

Wrapping Up

A secure website isn’t one that will never have any security-related issues – it would be impossible to promise that. Instead, a secure website is one where there are as many security risk reductions made as possible. The stronger and more secure your website, the less vulnerable it is to hacks.

Some security measures to keep your site from getting WordPress hacked are obvious and easy to handle on your own, like creating strong passwords and only opting for reputable plugins and themes. Others are more difficult to manage, though, especially if you’re in charge of numerous websites for clients.

Nobody wants to deal with the trouble of a WordPress hack. Your site will become unavailable to visitors, and your business can be impacted – and the longer your site is inaccessible, the greater the overall impact. Taking action fast is necessary.

So much of this can be automated and handled for you with the right host – they can take over regular backups, malware scans, security updates, encryption, and firewalls. Whether you’ve had a hacked site and never want to go through it again or you’d love to boast that your sites have never been hacked, quality security is key. Keeping your WordPress website up-to-date and partnering with a quality hosting partner like ASPHostPortal can prevent hacks from happening in the future.

Cheap Moodle 3.0.3 Hosting Recommendation

10 Extremely Helpful Visual Studio Code Plugins for Programmers

1. Visual Studio Intellicode

Image for post

2. Git Blame

Image for post

3. Prettier

4. JavaScript (ES6) Code Snippets

5. Sass

6. Path Intellisense

7. Debugger for Chrome

Image for post

8. ESLint

9. SVG Viewer

Image for post

10. Themes

Cheap Sitefinity 9.0 Hosting Recommendation

How To Change WordPress Password If You Forgot It

If you’re like us, chances are, every so often you will forget a WordPress Administrator password and you’ll need to reset it. Luckily, WordPress has quite a number of ways in which you can change an Administrator (or any other user) password, of course as long as you still have access to the website via your hosting account.

Reset your password via email

WordPress makes it very easy to reset your password if you have access to the original email that you had associated with your account. Simply visit the WordPress login page, and click on the Lost your Password link.

lost your password screenshot

You will then be asked to enter the username or the email address of the user whose password you have forgotten.

Once you do that, you will be sent an email with a link to reset the password. Click on the link and follow the instructions.

Change your WordPress password via PHPMyAdmin

Be Careful: Do not perform any modifications, delete or change any of the WordPress database tables if you do not know what you are doing.  You can potentially corrupt your database, lose information or delete your whole database.

You can change the admin password if you have access to PHPMyAdmin. Browse to PHPMyAdmin using the database administrator and password which you should have available as part of your WordPress web hosting details.

phpmyadmin to access WordPress users table

Now you’ll need to access the Users table in PHPMyAdmin:

On the left, you will see 2 links, click on the name of the database of the WordPress site you want to change the password for. You will see all the table names are prefixed with some letters, e.g. wp_

The table names are on the right of the Underscore.

Scroll down to the table  wp_users. Click on the ‘Browse‘ tab.

You will now see a list of users – you need to find the user which you want to change the password for. Click on the ‘Pencil‘ or Edit to edit the WordPress Administrator user.

The next screen is where you can change your password, find the user_pass field:

    • Change the user_pass dropdown to ‘MD5′
    • Enter in a new password in the text box beside it – you can enter it in plain text, the password will then be encoded by PHPMyAdmin

See the screenshot below of how your wp_users table should look like.  Then press Go.forgot WordPress administrator password

Once you have done this, your WordPress administrator password is changed.  You will see on the next screen that the password field changed to a bunch of letters and numbers that you didn’t enter.

That’s ok, because that’s how MySQL stores your password. Don’t forget this password too 🙂

Go to your WordPress Administrator login and try out the new username and password you entered.

Change your password via FTP or the File Manager of CPanel

 You can also change the password by changing a file via FTP or using the CPanel File Manager.

  • Access the files of your website via FTP or File Manager and edit the functions.php file of your current theme
  • Edit the functions.php file and add the following to it, at the very top right after the first <?php
wp_set_password( 'password', 1 );
  • Change the ‘password’ text with your new password for the admin user. The reason why we put “1” is because the user ID number in the wp_users table of the Administrator is usually 1 – although sometimes it may not be the case. In that case, you’d have to use the above method via phpmyadmin
  • Save the modified file back to your site – replacing the old version and access the front-end of your website, and make sure you refresh the site at least once
  • After refreshing, you should be able to log in
  • VERY IMPORTANT: Make sure that you remove this code by following the same procedure. Besides being a vulnerability because the password is stored in plaintext, the code will reset your password each time you access your site until you remove it.

And these ladies and gentlemen are the easiest ways to reset the WordPress administrator password if you forgotten it!

Cheap SQL Server 2016 Hosting Recommendation

How to Delete All Pending Comments in WordPress

Do you have a lot of pending comments in WordPress that you want to delete? This can easily happen if you get a lot of spam comments.

Normally, deleting comments in WordPress is easy, but it gets trickier when there is a large number of pending comments. You may even come across weird errors while bulk deleting comments if there are too many of them.

In this article, we’ll show you how to easily bulk delete all pending comments in WordPress, step by step.

What Are Pending Comments in WordPress?

Pending comments in WordPress are the comments that are awaiting moderation.

You’ll find them in the WordPress admin area by visiting the ‘Comments’ page and switching to the ‘Pending’ tab.

The number of pending comments showing in the WordPress admin sidebar and on the dashboard

We recommend users turn on comment moderation on all their websites to combat comment spam. This means all comments on your website will go to the Pending queue before they are approved.

Why would anyone want to delete pending comments?

There are many scenarios when you may need to do that. For instance:

  • Akismet anti-spam plugin got disabled on your site and suddenly all spam comments are appearing in pending.
  • You simply forgot about a website, and it gathered hundreds of comments that are no longer relevant.
  • Articles on your website generating a lot of unwanted comments
  • You forgot to turn off comments on older posts

It can take a long time to go through and moderate each comment individually. If you are confident that there are no comments marked ‘pending’ that you want to keep, then you can simply bulk delete them all.

1. Deleting All Pending Comments in WordPress Manually

If you only have a few hundred pending comments, it’s quite quick to delete them manually.

Simply go to the ‘Comments’ page in WordPress admin area and then click on the ‘Pending’ tab to see a list of all your pending comments.

By default, this list will show 20 pending comments at a time. To change this, click on the ‘Screen Options’ tab at the top-right corner of the page.

Opening up the screen options tab on the pending comments page

Next, type ‘100’ into the ‘Number of items per page’ and click the Apply button:

Changing the pagination for the comments to fit more on each page

Now that you have 100 comments displaying, simply check the box to the left of ‘Author’ at the top of the list of comments. This selects all the comments on the page:

Check the box to the left of Author to select all comments on the page

Then, click on the ‘Bulk actions’ dropdown and select the ‘Move to Trash’ option. Go ahead and click the Apply button to move all those comments into the trash:

Bulk selecting the pending comments and moving them to the trash

WordPress will automatically show the next 100 comments on the page. Simply repeat the process to remove these too.

When you delete any comment on WordPress, it is not deleted right away. Instead, it is sent to the ‘Trash’ and will remain there for 30-days. After that, it will be automatically deleted permanently.

If you would rather delete them permanently right away, then you need to switch to the ‘Trash’ tab on the ‘Comments’ page and then click on the ‘Empty Trash’ button.

Emptying the trash to delete all the pending comments from WordPress

You will then see a message confirming that those comments have been deleted:

WordPress showing a message to confirm that the comments have been permanently deleted

Note: You can use the Screen Options to show up to 999 comments per page. However, this will increase the load on your WordPress hosting servers and slow down your site. You might also see an error message like this one when you try to move comments to the trash:

Error message shown when trying to move too many comments to the trash at one time

If you have more than a few hundred pending comments, then we recommend using a plugin method to delete them.

2. Deleting Large Number of Pending Comments in WordPress Using a Plugin

The quickest way to delete a very large number of pending comments is to use a plugin.

This will delete your pending (and spam) comments permanently. We recommend making a backup of your WordPress site before proceeding, just in case you change your mind later.

First, you need to install and activate the Delete Pending Comments plugin.

Upon activation, go to the Comments » Delete Pending Comments page in your WordPress admin. You will see a message letting you know how many pending comments there are.

Note: This figure includes spam comments, which are deleted at the same time as the pending comments.

The Delete Pending Comments page in the WordPress admin

To delete all the pending comments, you need to type the required line of text into the box. You can copy and paste this text if you prefer.

After that, go ahead and click the ‘Delete Pending Comments’ button.

Enter the line of text in order to delete the pending comments

You will then see a message confirming that all pending and spam comments have been deleted.

Message confirming that all pending and spam comments have been deleted

Deleting Spam Comments Only in WordPress

What if you don’t want to delete pending comments but just want to delete the ones that are marked as spam? That’s very easy to do in WordPress.

First, go to Comments in your WordPress admin and click on the Spam tab:

Click on the Spam tab to see a list of comments that have been marked as spam

Next, click the Empty Spam button. This will delete all spam comments permanently, not just the ones on the current page:

Empty the spam to permanently delete all spam comments

We hope this article helped you learn how to delete all pending comments in WordPress.

Cheap Umbraco 7.4.1 Hosting Recommendation

Top 10 Node.js Performance Tips

Javascript has witnessed exponential growth in the field of app development. And that too, with the inception of Node JS, the growth has been doubled. Node JS needs no introduction as it is the best in the industry of building top-class web servers with unmatched quality.

Moreover, the Node JS can build quick and scalable applications, which is an added advantage apart from its asynchronous and event-driven nature. Delivering high-end performance is what Node JS is known for, and that ensures a quality project as well.

Well, we cannot completely favor Node JS by highlighting its good side, there may be some common Node JS mistakes from which it may have gained a lot of learnings. Also, the mistakes might have impacted the performance as well.

This article will elaborate on a few Node.js Performance Tips that could boost the throughput, reduce the latency rate, and ensure maximum productivity from the app professionals.

1. Restrictive Use Of Synchronous Functions

Asynchronous API doesn’t let you down in delivering high performance. As you might be knowing that the Node JS is single-threaded, which means it has numerous synchronous components that would block the apps.

This may end up slowing down the performance, which could deliver not so desired results. Below is an attached code snippet which explains the operations read by file by sync and async:

// Asynchronous
fs.readFile('file.txt', function(err, buffer) {
  var content = buffer.toString();
});

// Synchronous
var content = fs.readFileSync('file.txt').toString();

2. Use Gzip Compression

Another addition to Node.js performance tips is the usage of gzip compression. It helps in compressing or decompressing the files. This can be elaborated; when a browser asks for a resource, a server to save time and reduce the latency rate will compress the response.

Using gzip at the time of either answering the clients or requesting the server operating remotely would ensure a great boost to the performance.

3. Lightweight and Small Code

If you are successful in making your web app’s code light in weight and small size, then you have won half the battle. The reduction in code size could result in boosting the productivity ratio and saves time. This can prove to be an effective tip to improve Node JS speed.

Also, there should be restrictions in unnecessary things that can hamper performance, like using a heavy framework that may drain a lot of RAM, using irrelevant modules, and many more things.

Moreover, there is another way that can contribute in enhancing performance, which is by combining various Javascript files into one.

4. Parallel Approach

Developing web apps would ask for multiple internal calls for extracting out data or information. There are multiple functions, and this process could consume a lot of time, which can also affect the performance of the application.

Here, executing the functions parallelly is possible with the help of Node JS as it has asynchronous nature. It can improve the Node JS speed as well as performance. The independent functions can be run parallelly. Also, it would eliminate the middleware functions that will add up in improving the speed.

Below is the code snippet to understand the parallelizability of functions working together:

function runInParallel() {
  async.parallel([
    getUserProfile,
    getRecentActivity,
    getSubscriptions,
    getNotifications
  ], function(err, results) {
    //This callback runs when all the functions complete
  });
}

5. User Caching

Caching is the process wherein you can store the often-used data or not so modifying data or information, which may improve Node JS speed in loading and also saves a lot of time. It will be better understood by the below snippet that clearly shows the recent data on display:

var router = express.Router();

router.route('/latestPosts').get(function(req, res) {
  Post.getLatest(function(err, posts) {
    if (err) {
      throw err;
    }

    res.render('posts', { posts: posts });
  });
});

It is done only on the frequent posts to speed up the loading time. The data which are rarely used should not be excluded from caching.

6. Render Static Assets Without Using Node JS

Well, not using Node JS for rendering the static content would be another tip for boosting Node JS performance. Yes, you read it, right! Nginx, a standard web server, should be used to render static assets like CSS or images.

This will help in reducing the memory load on Node JS and will also not impact the performance of the application.

7. Front-End Rendering

Angular JS and Backbone JS are the front-end frameworks that follow the MVC architectural pattern, which makes it possible to construct single-page applications. It automatically delivers the responses to the client bypassing the server, which allows the developers to understand which APIs are responsible for it.

If you want to save your bandwidth, then use front-end rendering in Node JS, which will also help you in reducing the latency rate and increasing the productive ratio. Moreover, it turns out to be a potential tip for boosting Node JS speed & performance.

8. No Storing

Session data can lead to overload the memory as it gets stored by default. The excess storing of data would even hamper the performance. So, it is advisable either not to store data in sessions or keep some other storage data.

For better understanding, let’s look at an example, you should store ID in of the user whoever uses your application instead of storing the entire object, which could reserve a lot of memory. For storing the data, you can use MongoDB or Redis.

9. Use of Standard V8 Functions

There are multiple collections like maps, reduce, and forEach that don’t have support from all the browsers. Well, it can be said that there can be compatibility issues, which can be one of the reasons for no bolstering of collections.

But, with the help of Node JS’s Google V8 JS engine, you will get to know the supported operations and collections. This can be leveraged for diverting the collections on the back-end.

10. Resolve Memory Leaks

Node JS performance tips include resolving of memory leaks issues. As Node JS V8 engine has a garbage collector that helps in processing the inactive and unused memory by cleaning it so that it can be used whenever required.

The garbage collector can sometimes fail to clean the memory, which needs to be fixed it asap. It is 10x tougher to track or monitor memory leakage, but memory heap snapshots can help you in verifying classes and objects that are growing at a gradual rate.

Conclusions

The memory leak is a major problem in Node JS, which could hamper the performance of the applications. The Node.js Performance Tips mentioned above should be strictly implemented to enhance or boost performance.

Undoubtedly, it requires more improvements, but until the time the new improvement comes, this effective measure can help in advancing the speed of applications.

If you want to boost the performance of your Node JS application, then you can hire Node JS developer, who will help you in setting up your project. The team is qualified, skilled, and have years of hands-on experience in building quality projects.

Cheap ASP.NET 4.6 Hosting Recommendation

What’s New in SharePoint Framework (SPFx 1.10)?

Introduction

A very quick definition of SharePoint Framework: It is an application framework used to build and extend modern experiences in SharePoint.

The only option that’s been available in the initial SPFx release (in early 2017) webparts, and later 2017 extensions been released to customize more facets of the SharePoint experience, including notification areas, toolbars, and list data views.

SPFx features hosted scenarios in classic, modern, system pages, App pages & with Teams are either webparts / extensions or both as below.

This framework is evolving constantly. Microsoft announced major development areas in the SPFx framework, and the below features are quite impressive. We are going to discuss this in forthcoming articles and a more detailed discussion with the GA feature in the new SPFx 1.10 framework.

The interesting areas are:

  1. Web Parts
  2. Extensions
  3. Domain Isolated webparts
  4. App Pages
  5. Graph API support
  6. Support for Teams &
  7. Supporting 3rd party API’s with AAD security

The SPFx 1.10 release has the below General Availability features:

  • Pre-allocated application customizer placeholders
  • SharePoint Framework for Teams – Personal tab support
  • SharePoint Framework for Teams – Added support for Teams mobile app
  • List notification API

And Developer Preview Features has:

  • Query modification extension
  • SPFx support for Office Add-ins
SEO Tips - SEO Friendly URL Structure in WordPress

Bootstrap in ASP.NET MVC Tutorial

Introduction

  • MVC is a framework for building web applications with the MVC design.

Now what is MVC?

  • MVC is a model-view-control design that seprates buisness logics ,UI design and user interaction.
    mvc
  • Model deals with the business layer that is classes and the properties.
  • View is the part that deals with the display of data on the screen.
  • Controller interacts with the view and gets the user inputs from view.
  • Controller sends input to the model and in return, model sends output to the controller after performing actions.
  • Controller then displays the output on screen.
  • In traditional webform pattern code and design file is same and if we place the control on the design page that reflects in the code file also.
  • In Mvc design this file system is replaced.Here we put all the logic in one file called controller.From one controller we can call different UI.
  • In controller there is ActionResult that returns action against the ActionResult.
  • There is a view created against the ActionResult with the same name as the action result.
  • If we created the view against an ActionResult then in the Views folder a folder is created with the same name as of controller containing the views of that controller only.
Start by creating the project
  • Open the VS create new project,find ASP.NET MVC 4 Web Application.
    Open
  • After that a window appears select Internet Application and click OK.
    Internet Application
  • Mvc project will be created.
  • SolutionExplorer shows many folders.
    folders
  • Here in the solution explorer every folder has unique meaning.
  • Properties folder contains the version information and some other information about the project.
  • References store the refrence dlls required in the project.
  • App_Start contains the configuration files.
  • Content folder contain the css files.
  • Controllers folder contain the controllers for code.
  • Models folder contain the classes for buisness logics.
  • Scripts contain the javascript files.
  • Views folder contains views for the controllers.

Download CSS and JS files for bootstrap.

  • Go to the References folder right click on the folder >Find>Manage NuGet Packages>Click on the option.
  • Install bootstrap package.
    boostrap
  • Bootstrap is installed automatically and css files are saved in content folder and js files are saved in script folder.

Now register css and scripts for entire project.

  • Go to the App_Start folder > Open BundleConfig.cs,
  • Delete the code in the RegisterBundles method and replace with the given code.
public class BundleConfig    
   {    
       public static void RegisterBundles(BundleCollection bundles)    
       {    
           StyleBundle(bundles);    
           ScriptBundle(bundles);    
       }   

       public static void StyleBundle(BundleCollection bundles)    
       {    
           bundles.Add(new StyleBundle("~/css")    
                    .Include("~/Content/bootstrap.css"));    
       }    

       public static void ScriptBundle(BundleCollection bundles)    
       {    
           bundles.Add(new ScriptBundle("~/js")    
                    .Include("~/Scripts/jquery-{version}.js")    
                    .Include("~/Scripts/bootstrap.js"));    
       }    
   }
  • StyleBundle method register the css files.
  • ScriptBundle method register the js files.
  • Check the path of the files.
  • ~/css and ~/js are the root path for css and js files.
  • Call the both methods in the RegisterBundle method.
  • Check the path of the files carefully.
Now create the layout page for the entire project.
  • Go to the views folder find shared folder inside views folder.
  • Open _Layout.cshtml present in shared folder.
  • Write below given code,
<!DOCTYPE html>    
<html lang="en">    
<head>    
    <meta charset="utf-8" />    
    <title>@ViewBag.Title - My ASP.NET MVC Application</title>    
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />    
    <meta name="viewport" content="width=device-width" />    
    @Styles.Render("~/css")    
</head>    
<body>    

    <nav class="navbar navbar-inverse">    
        <div class="container-fluid">    
            <!-- Brand and toggle get grouped for better mobile display -->    
            <div class="navbar-header">    
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">    
                    <span class="sr-only">Toggle navigation</span>    
                    <span class="icon-bar"></span>    
                    <span class="icon-bar"></span>    
                    <span class="icon-bar"></span>    
                </button>    
                <a class="navbar-brand">Mvc App</a>    
            </div>    
    
            <!-- Collect the nav links, forms, and other content for toggling -->    
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">    
                <ul class="nav navbar-nav">    
                    <li class="active"><a href="#">1st LINK</a></li>    
                    <li><a href="#">2nd Link</a></li>    
                    <li class="dropdown">    
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Link Dropdown<span class="caret"></span></a>    
                        <ul class="dropdown-menu">    
                            <li><a href="#">SubLink1</a></li>    
                            <li><a href="#">SubLink2</a></li>    
                            <li><a href="#">SubLink3</a></li>    
                            <li role="separator" class="divider"></li>    
                            <li><a href="#">SubLink4</a></li>    
                            <li role="separator" class="divider"></li>    
                            <li><a href="#">SubLink5</a></li>    
                        </ul>    
                    </li>    
                </ul>                  
                <ul class="nav navbar-nav navbar-right">    
                    <li><a href="#">Right side links</a></li>    
                    <li class="dropdown">    
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Link Dropdown<span class="caret"></span></a>    
                        <ul class="dropdown-menu">    
                            <li><a href="#">1st Link</a></li>    
                            <li><a href="#">2nd Link</a></li>    
                            <li><a href="#">3rd Link</a></li>    
                            <li role="separator" class="divider"></li>    
                            <li><a href="#">4th Link</a></li>    
                        </ul>    
                    </li>    
                </ul>    
            </div>    
            <!-- /.navbar-collapse -->    
        </div>    
        <!-- /.container-fluid -->    
    </nav>    
    <div class="container">    
        @RenderBody()    
    </div>    
    
    @Scripts.Render("~/js")    
    @RenderSection("scripts", required: false)    
</body>    
</html>
  • In the code given above we define the layout for entire project.
  • @Styles.Render(“~/css”) this is used to render the css files that included in the bundleConfig.cs file.
  • In the body tag nav bar is placed that is used to place the links for the page redirection.
  • This layout of bootstrap is fully responsive.
  • @RenderBody() is used to render the content on the page.
  • @Scripts.Render(“~/js”) include all the js files that included in the BundleConfig.cs file.
  • Now HomeController is created automatically inside the controllers folder.
  • View against the ActionResult is also created automatically.
  • Now inside the views folder find folder named Home ,find Index.cshtml view inside the Home folder.
  • Replace the code with the below given code.
@{    
    ViewBag.Title = "Home Page";    
}    
<h1>Your 1st MVC app created.</h1><br />    
<h1><a href="">Click here next part is pretty intresting.</a></h1>
  • Now run the application.Result will look like this.
    result
Start with your own project.

How To Create Database Table in Magento

Module File Structure

We updated our module file structure looks as follows:

magetop helloworld file struture

Create file module.xml and registration.php

The job of creating these 2 files I have detailed instructions and explanations in the previous article. You can read it here.

Create file InstallSchema.php

You create this file according to the path: Magetop/Helloworld/Setup/InstallSchema.php.

We will create a table name magetop_blog with fields: id, title, description, created_at, status.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace Magetop\Helloworld\Setup;
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\ModuleContextInterface;
class InstallSchema implements InstallSchemaInterface
{
    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;
        $installer->startSetup();
        $tableName = $installer->getTable('magetop_blog');
        //Check for the existence of the table
        if ($installer->getConnection()->isTableExists($tableName) != true) {
            $table = $installer->getConnection()
                ->newTable($tableName)
                ->addColumn(
                    'id',
                    Table::TYPE_INTEGER,
                    null,
                    [
                        'identity' => true,
                        'unsigned' => true,
                        'nullable' => false,
                        'primary' => true
                    ],
                    'ID'
                )
                ->addColumn(
                    'title',
                    Table::TYPE_TEXT,
                    null,
                    ['nullable' => false, 'default' => ''],
                    'Title'
                )
                ->addColumn(
                    'description',
                    Table::TYPE_TEXT,
                    null,
                    ['nullable' => false, 'default' => ''],
                    'Description'
                )
                ->addColumn(
                    'created_at',
                    Table::TYPE_DATETIME,
                    null,
                    ['nullable' => false],
                    'Created At'
                )
                ->addColumn(
                    'status',
                    Table::TYPE_SMALLINT,
                    null,
                    ['nullable' => false, 'default' => '0'],
                    'Status'
                )
                //Set comment for magetop_blog table
                ->setComment('Magetop Blog Table')
                //Set option for magetop_blog table
                ->setOption('type', 'InnoDB')
                ->setOption('charset', 'utf8');
            $installer->getConnection()->createTable($table);
        }
        $installer->endSetup();
    }
}

Create file InstallData.php

Next, we will insert data for the magetop_blog table.

You create this file according to the path:Magetop/Helloworld/Setup/InstallData.php.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace Magetop\Helloworld\Setup;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
class InstallData implements InstallDataInterface
{
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();
        $tableName = $setup->getTable('magetop_blog');
        //Check for the existence of the table
        if ($setup->getConnection()->isTableExists($tableName) == true) {
            $data = [
                [
                    'title' => 'How to Speed Up Magento 2 Website',
                    'description' => 'Speeding up your Magento 2 website is very important, it affects user experience. Customers will feel satisfied when your site responds quickly',
                    'created_at' => date('Y-m-d H:i:s'),
                    'status' => 1,
                ],
                [
                    'title' => 'Optimize SEO for Magento Website',
                    'description' => 'One of the important reasons why many people choose Magento 2 for their website is the ability to create SEO friendly',
                    'created_at' => date('Y-m-d H:i:s'),
                    'status' => 1,
                ],
                [
                    'title' => 'Top 10 eCommerce Websites',
                    'description' => 'These are the websites of famous e-commerce corporations in the world. With very large revenue contributing to the world economy',
                    'created_at' => date('Y-m-d H:i:s'),
                    'status' => 0,
                ],
            ];
            foreach ($data as $item) {
                //Insert data
                $setup->getConnection()->insert($tableName, $item);
            }
        }
        $setup->endSetup();
    }
}

Increase the version in module.xml

If you have just created this module and you have not declared it on the database yet, you do not need to increase the version in module.xml

If you have already declared this module on the database, please increase the version in module.xml

increase version

Run the command

You need to run 2 commands:

php bin/magento setup:upgrade
run setup upgrade
php bin/magento setup:db-schema:upgrade
run setup schema upgrade

Check in the database

Please check on the database and You will see your accomplishment.

check in database 1
check in database

Upgrade table in the database

Next, I will guide you to add fields to the created table and create a new table in UpgradeSchema.php.

You create this file according to the path: Magetop/Helloworld/Setup/InstallData.php.

In the following code, I will implement two field image, category_id and create a new table magetop_blog_categories.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
namespace Magetop\Helloworld\Setup;
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
class UpgradeSchema implements UpgradeSchemaInterface
{
    public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();
        //Add new fields to the created table
        if (version_compare($context->getVersion(), '1.0.2') < 0) {
            $table = $setup->getTable('magetop_blog');
            //Check for the existence of the table
            if ($setup->getConnection()->isTableExists($table) == true) {
                // Declare data
                $columns = [
                    'image' => [
                        'type' => Table::TYPE_TEXT,
                        ['nullable' => true],
                        'comment' => 'Image',
                    ],
                    'category_id' => [
                        'type' => Table::TYPE_INTEGER,
                        ['nullable' => false, 'default' => 0],
                        'comment' => 'Category ID',
                    ],
                ];
                $connection = $setup->getConnection();
                foreach ($columns as $name => $definition) {
                    $connection->addColumn($table, $name, $definition);
                }
            }
        }
        //Create a new table
        if (version_compare($context->getVersion(), '1.0.2') < 0) {
            $categories = $setup->getTable('magetop_blog_categories');
            //Check for the existence of the table
            if ($setup->getConnection()->isTableExists($categories) != true) {
                $tableCategories = $setup->getConnection()
                    ->newTable($categories)
                    ->addColumn(
                        'cat_id',
                        Table::TYPE_INTEGER,
                        null,
                        ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
                        'Category Id'
                    )
                    ->addColumn(
                        'status',
                        Table::TYPE_SMALLINT,
                        null,
                        ['nullable' => false, 'default' => 1],
                        'Status'
                    )
                    ->addColumn(
                        'cat_title',
                        Table::TYPE_TEXT,
                        null,
                        ['nullable' => false, 'default' => ''],
                        'Category Title'
                    )
                    ->addColumn(
                        'created_at',
                        Table::TYPE_TIMESTAMP,
                        null,
                        ['nullable' => false],
                        'Created At'
                    )
                    //Set comment for magetop_blog table
                    ->setComment('Magetop Blog Categories')
                    //Set option for magetop_blog table
                    ->setOption('type', 'InnoDB')
                    ->setOption('charset', 'utf8');
                $setup->getConnection()->createTable($tableCategories);
            }
        }
        $setup->endSetup();
    }
}

We will insert data for the magetop_blog_categories table.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Magetop\Helloworld\Setup;
use Magento\Framework\Setup\UpgradeDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
class UpgradeData implements UpgradeDataInterface
{
    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();
        if (version_compare($context->getVersion(), '1.0.2') < 0) {
            $tableName = $setup->getTable('magetop_blog_categories');
            //Check for the existence of the table
            if ($setup->getConnection()->isTableExists($tableName) == true) {
                $data = [
                    [
                        'cat_title' => 'News',
                        'status' => 1,
                        'created_at' => date('Y-m-d H:i:s'),
                    ],
                    [
                        'cat_title' => 'Tutorials',
                        'status' => 0,
                        'created_at' => date('Y-m-d H:i:s'),
                    ],
                    [
                        'cat_title' => 'Uncategorized',
                        'status' => 0,
                        'created_at' => date('Y-m-d H:i:s'),
                    ]
                ];
                foreach ($data as $item) {
                    //Insert data
                    $setup->getConnection()->insert($tableName, $item);
                }
            }
        }
        $setup->endSetup();
    }
}

Do not forget to increase the version in module.xml!.

Finally, run the two commands above and enjoy the result.

check magetop blog categories table
check new field in magetop blog table
check magetop blog categories in database

I hope through this series you can create your own complete module. Good luck!

error: Content is protected !!