Should I create Git repository in public_html or different folder?

It is generally not recommended to create a Git repository directly inside the `public_html` folder of your web server. The `public_html` (or `public` or `www`) directory is typically the web server’s root directory, and its contents are accessible to the public through the internet. Placing your Git repository there could expose sensitive information and potentially compromise your code’s security.

Instead, it is a good practice to keep your Git repository outside the `public_html` folder and use a deployment strategy to publish your code to the web server.

Here’s a common directory structure:

In this setup, the `public_html` folder contains only the files necessary to serve your website to the public. Your actual code resides in the `git_repository` folder, which is not accessible to the public.

When you’re ready to deploy a new version of your website, you can use various methods to transfer the relevant files from the Git repository to the `public_html` folder. Some common deployment strategies include:

1. Git pull (or clone) on the server: SSH into your server, navigate to the `git_repository` folder, and pull the latest changes from your remote repository. Then, copy the required files to the `public_html` folder.

2. Deploy script: Write a script that automates the deployment process. The script can pull the latest changes from the Git repository and copy the necessary files to the `public_html` folder.

3. CI/CD tools: Use continuous integration and continuous deployment (CI/CD) tools like Jenkins, Travis CI, or GitHub Actions to automate the deployment process whenever you push changes to your Git repository.

Using one of these deployment strategies will help keep your sensitive code and configuration files secure, while still allowing you to publish your website to the public_html directory for the world to access.

WordPress Custom Fields missing in admin (post or page)

This is a very specific problem so it might only work for some. After I updated WordPress and all plugins on an old site that used WordPress Custom Fields to enter some data, the Custom Fields in admin disappeared. I could add a new post but Custom Fields were nowhere to be sen, not even in the screen options.

Long story short, after doing some searching on the net, I found out it was ACF (Advanced Custom Fields) fault. In new version of the plugin they disable WordPress Custom Fields because they think you are using ACF anyway so no need for both. Not sure I agree but here is 2 ways you can try to solve it:

  1. If you activated ACF but are not using the plugin, just disable it.  WordPress Custom Fields should come back.
  2. If you want to keep both then add this code to your theme’s function.php file (the best is the child theme, if you have one)
    add_filter('acf/settings/remove_wp_meta_box', '__return_false');

WordPress Custom Fields should reappear now.

Using Laragon for Laravel projects

I am in the process of migrating one of my sites from Codeigniter (anyone remember it? It promised so much but then fell behind, especially when Laravel came out years ago) to Laravel. It’s been a while since I used Laravel but I always love developing with it.

I always use XAMPP for local development but luckily I googled for alternatives and found Laragon. What an awesome find. At first I thought it was just for Laravel, due to name Laragon but you can use it for everything.

So here is how easy it was to install latest Laravel and start local development.

  1.  Go to Laragon website and download it, full or lite. Install (also select development folder) and start the services. Now you have a running web server!I changed few preferences (I don’t want it to start with Windows but I want it to start minimized and start ALL services at once) but you can do whatever is best for you.Another great thing: It comes with my favorite Console Emulator CMDER (not my screenshot):
  2. Let’s install Laravel. Right click blue (or green) Laragon tray Icon -> Quick App -> Laravel, name the project (folder)  and Laragon will begin to install Laravel via console. If you get asked for admin permission to open console (for hosts if I remember correctly) say yes.   When it finishes you should be able to open the web at ProjectName.test . I have to say that the first time I installed Laravel the scripts in console did not finish so it didnt work. I deleted the project folder, restarted the step  2. again and then it worked – Laravel was installed!
    laragon install laravel
  3.  I noticed that phpmyadmin was not installed. It is super easy again to install it :  Right click blue (or green) Laragon Icon -> Tools -> Quick Add -> *phpmyadmin . Wait few moment and you can access it at localhost/phpmyadmin/

And that is all. I installed local web server, Laravel and phpmyadmin with few clicks.

Share localhost over the internet with ngrok

One of the more annoying things when developing on your local computer is that your clients or friends can’t see what you develop. You can upload it on your web server or you can work directly on the web server but that is inconvenient and slow. So I was very happy to discover this great tool called ngrok. There are similar tools (localtunnel etc) but this one is really easy to use.

Who is your daddy and..no..wait..what is ngrok and what does it do?

Ngrok is a cool little program that creates a tunnel from the public internet (http://subdomain.ngrok.com) to a port on your local machine. You can give this URL to anyone to allow them to try out a web site you’re developing without doing any deployment. Of course your local server has to run at the time of sharing but that is not a problem – you just leave your PC on.

How do I run this ngrok?

With ngrok it is super simple to expose a local web server to the internet. On Windows you just download ngrok.exe, unzip it some folder and then in command prompt (cmd) you just tell ngrok which port your web server is running on.

This is the most simple way (This opens port 8080 on your local machine to the internet). Type this in your command prompt:

ngrok 8080

You will see something like this :

Tunnel Status                 online
Version                       0.11/0.8
Protocol                      http
Forwarding                    http://345355bc.ngrok.com -> 127.0.0.1:8080
Web Interface                 http://localhost:4040
# Conn                        0
Avg Conn Time                 0.00ms

Of course the port (in this case 8080) has to be the port that your localhost is running on. Now just give the generated URL (in our example http://345355bc.ngrok.com) to your client or friend and let them test out your application.

You can do a lot more with ngrok, like inspecting your traffic, XML/JSON syntax checking, replaying requests, requiring passwords to access your tunnels, accessing your tunnels over HTTPS, forwarding non-HTTP services, forwarding to non-local services and more.

Check out ngrok here.

How to remove horizontal scrollbar in Twitter Bootstrap tab function

While building my new admin/CMS with Laravel 4 and Gebo Admin (really cool twitter bootstrap responsive admin template) I encountered weird problem while using bootstrap tabs –  after I added “enhanced select” (Country dropdown) suddenly a horizontal scroll bar appeared!

How to remove horizontal scrollbar in tab function twitter bootstrap

I am not sure if this is 100% best solution (I am not that keen on digging into all this .js stuff) but the easiest way to fix this is to open Bootstrap.min.css, search for .tab-content and then replace

overflow: auto;

with

overflow: hidden;

Reload your page and the horizontal scrollbar is gone.

Missing XML tag This required tag is missing. Please add it and resubmit ror.xml

Why do I need sitemap?

Sitemaps are a very useful way to  allow a webmaster to inform search engines about URLs on a website that are available for crawling. If you are using WordPress or some other CMS you can simply install a plugin (or maybe XML sitemap generation is already inbuilt module) and it will automatically create a sitemap for you. But sometimes you want to create a sitemap by yourself. There are several free services that allow you to create sitemaps for free, like xml-sitemaps.com , rorweb.com and so on. After you create a sitemap you should upload it to your website and submit to to Google,Yahoo etc.

That was a little sitemap introduction and now to the problem I encountered.I am not going to go into discussion if ROR sitemaps are better than Google/XML sitemaps or even needed (I don’t really use it but some people might find it useful). I am just describing solution to a possible problem you might encounter when making a ROR sitemap.

Google Webmaster Tools and ror.xml error

I built a ROR sitemap using xml-sitemaps.com site,uploaded to my site  and added it in Google Webmaster Tools admin and Google showed me this error:

Missing XML tag
This required tag is missing. Please add it and resubmit.

Parent tag: channel
Tag: description

At first I thought that xml-sitemaps.com ROR generator is outdated so I used one at rorweb.com/rormap.htm but I got the same error.  After searching the net I found the solution is very simple:

Open the ror.xml file in your text editor and find this (the beginning of the document,it might look a little different)

<channel>
<title>ROR Sitemap for http://www.yoursite.com/</title>
<link>http://www.yoursite.com/</link>
<item>

and paste the description line between the title the link lines so it will look like this:

<channel>
<title>ROR Sitemap for http://www.yoursite.com/</title>
<description>ROR Sitemap for http://www.yoursite.com/</description>
<link>http://www.yoursite.com/</link>
<item>

Save the file,reupload to your server and resubmit to Google Webmaster Tools (refresh the page) and the ‘Missing XML tag This required tag is missing. Please add it and resubmit’ error should disappear.