CodeIgniter Forums
Codeigniter and phpstorm and github - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Codeigniter and phpstorm and github (/showthread.php?tid=80363)

Pages: 1 2


Codeigniter and phpstorm and github - richb201 - 10-23-2021

I use phpstorm and have a need to maintain both a production site and a staging site. I was advised to use git and github to keep these two separate. But how do I do this with a site I maintain with a phpstorm project. Do I keep the projects up on git hub and bring  then down prior to working on it, locally? What is the "best practice" on keeping two different copies?


RE: Codeigniter and phpstorm and github - wdeda - 10-23-2021

You can use Apache's vhost to do this. A production site and a development site and both, if you like, can be on Github. You can install, just as an example, different versions of frameworks, etc.
Access to this file: \Apache\conf\extra\httpd-vhosts.conf
Code:
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/wdsite/public"
    ServerName localhost
    ErrorLog "logs/wdsite-error.log"
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/wdtest/public"
    ServerName wdtest
    ErrorLog "logs/wdtest-error.log"
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/wdtools/public"
    ServerName wdtools
    ErrorLog "logs/wdtools-error.log"
</VirtualHost>

If you are using Windows you will have to change the 'hosts' file, in C:\Windows\system32\drivers\etc\hosts, as admin. Below is an example of the host file::
Code:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

127.0.0.1 localhost
127.0.0.1 wdtest
127.0.0.1 wdtools



RE: Codeigniter and phpstorm and github - InsiteFX - 10-24-2021

Once you clone the GitHub repositoriy it phpStorm will know its a GitHub project.


RE: Codeigniter and phpstorm and github - richb201 - 10-24-2021

Thanks. I am not really clear about something. I need to keep two separate servers. Will I just have one repo and staging will just be a branch? I suspect that repo will be on Github? Now I had some put in a CICD a while back on my repo on Github. How does this work with branches?


RE: Codeigniter and phpstorm and github - wdeda - 10-24-2021

I don't know phpstorm, I use VSCode, but I don't believe that it hinders our understanding.
It is a single server, Apache, with one or more virtual servers. You will then have a production server, localhost, and a development server. Both can be used simultaneously, in different tabs, in a browser, for example.

My biggest difficulty will be in relation to git/github, because I use a Microsoft tool, which owns GitHub, called Github Desktop, which is integrated with Git and VSCode, with a graphical interface. It allows you to independently create and manage repositories locally and on GitHub. As a phpstorm user I believe this is out of the question.

xampp htdocs / creating repository with GitHub Desktop

[Image: 8ErxuYXs_t.jpg]  [Image: aI0vjduH_t.jpg]


RE: Codeigniter and phpstorm and github - richb201 - 10-24-2021

That raises some good questions. I actually developed under docker, not to make my life more difficult, but to be able to be sure that my code would run the same on the server as it does on my localhost. Alas, I found that some of tools I want to use REQUIRE that the app be running on the live internet. So much for my plans. So I then found that I needed two servers, one which is wired specifically to allow phpStorm to do remote debug. Then I found that I needed separate databases for the staging server (debug) and the production server. Then I need different docker-compose files for each to attach them to the correct database.

Now on top of all of this, I need to keep two copies of the code. I guess that mean that I need two repos. Now a while ago I had someone create a CICD tunnel from my production repo on github. I guess this means that once I update this repo, the code will automatically get transferred to the live production server? But where does my staging repor live? Is that just a branch from the main (CICD) repo?

I guess I need someone to set up my github development environment?


RE: Codeigniter and phpstorm and github - John_Betong - 10-24-2021

@richb201,
> I use phpstorm and have a need to maintain both a production site and a staging site

I have tried numerous ways to maintain different application versions and currently use the following on my Ubuntu VPS:

1. have a mirror image of LOCALHOST and ONLINE application versions
2. use Command line RSYNC to update online version, which only takes seconds
3. set and test for “LOCALHOST” which is a bool constant in index.php. This constant is available throughout the project and used to maybe ”if(LOCALHOST) {“ require videos, adverts, etc
4. use GitHub Command line “Git add .”, update and Git push for backups
5. the local MySQL database is for my local testing benefit and online database dynamically updated
6. online database manually downloaded to local backups and sometimes used locally
7. I’ve setup completely separate staging sites using subdomains and also used “freenom.com” free domains.
8. The completed staging site directory is copied to a version-123 directory, etc


RE: Codeigniter and phpstorm and github - richb201 - 10-24-2021

Wow! Not that easy! I was developing on localhost and that worked well. But now with the stuff needing to be up on the live internet, I am kind of stuck with my remote debug. That's OK.
But I am concerned about the github repo. It seems that I have two local repos called master-new, and main. On origin I have three repos: master, master-new, and main. What these are all for? I have no idea.

What I really need is to be able to populate two different domains; regular and staging.


RE: Codeigniter and phpstorm and github - wdeda - 10-24-2021

From June 2020:
GitHub is working on replacing the term "master" on its service with a neutral term like "main" to avoid any unnecessary references to slavery,
you can read here for more background the reason for the change https://www.zdnet.com/article/github-to-replace-master-with-alternative-term-to-avoid-slavery-references/
about renaming your branch from master to main: there are a lot of guidelines for example here https://jarv.is/notes/github-rename-master/

========================

Of course, my knowledge is a long way from yours, but there is a question that I think is fundamental to ask: Are there multiple versions of GitHub? Because the difficulties reported by you, I never imagined that they could exist.
It's a matter of personal choice, but I find it strange to use an IDE to increase productivity, among other things, but still using CLI.
Wouldn't it be time to reassess the tools and means used?

The big problem with today's youth is that I'm not part of it.


RE: Codeigniter and phpstorm and github - John_Betong - 10-24-2021

@richb201,
Please explain in detail why online debugging is required. In extreme cases I’ve passed and tested for a $_GET variable to render relevant data.

Are you using Windows, Mac, Linux?

Have you tried RSYNC? It’s wonderful, only uploads changed script and zip/unzips differences!