Thursday, March 11, 2021

Executing Git Commnads from PHP

 This a continuation of my previous post about the new project I have in mind. I am currently using Git as my version control software and commands are usually entered at the cmd environment or the git-bash software.

I already know that PHP has the command shell_exec to run batch files or external executable files so it should be easy to accomplish this task. I am going to show how I did it:

  • shell_exec can not work directly to execute the git commands,  but it has already proven that it can run .exe and .bat file. 
  • I opted to create a .bat file but the problem with this file is that I could not capture its output. It has no control over the process being created which means it does not have to wait for a line to finish before going to the next, fortunately, vb6 has this feature that's why vb6 is an indispensable tool  for me.
  • So I created a .exe file from vb6. What this program does is to run the .bat file and capture its output and save it to a text file
  • And after creating this, the php scritpt will run the .exe file and then display the content of the text file.    
It should be noted that this is for offline applications. I encountered a lot of  difficulties but finally I was able to make it work. 

More details of the programs I created.

1. VB6 .Exe File
The vb6 program consists of a module with a few api declarations and a function. The api declarations are necessary to activate the detection of the ending of the process created when the program executes the .bat file. The vb6 startup is the subroutine main().

Here's api declaration:

The subroutine main() calls the function Shellsync with 2 parameters, the batch file name and vbHide(a vb6 system variable that instructs the shell command to hide the window that the process being created when it executes the batch file. And the function Shellsync the one responsible for executing the batch file and catch the output to a text file. The actual command to save the output to a text file is a common dos command:


 2. The batch file.

I created a .bat file to handle 2 git commands and its very very simple:


 

 3. And lastly the php script is also very simple:

 


 4. Before I forget, all three files are located on the same folder:


 

 

 


Tuesday, March 9, 2021

New project In Mind

 For very large software development projects, code versioning is an indispensable tool to avoid  any losses should there be data corruption in the codes. It is like in this scenario:

"Hey, this is working before but now it isn't because of the revisions team A has done, I need to make it work because its holiday, for sure a lot of online shoppers will access their account to do more shopping, we do not want to miss this opportunity."

It's a huge disaster if the team could not restore the previous version known to work. Having a nice file version control software is not enough, I think it is also important to get statistics like how many commits has been done for the day, what's the status of the current revisions, do I need to commit the changes to my code without securing approval? So I thought maybe a separate web application must be done for this. 

This can be a very complicated  web based application but this system is very valuable for software development companies. That's why, I am also very excited to develop web app like this.

The web app shall composed of 5 modules which are as follows:

  1. User Management system
  2. Programming IDE
  3. Dashboard
  4. Project Management System
  5. Collaboration System
  6. Social Media


Dropdown Login Form using pure CSS

 I know that adding a dropdown login form can be done with sophistication using bootstrap. This was on top of my list when it comes to this particular task but given the circumstances, I opted to use CSS/Javascript because I encountered several errors with Bootstrap and it such a very inconvenience to modify my existing codes just to make it work.

The errors I encountered when I used bootstrap were as follows:

  • The left sidebar was deformed after I declared bootstrap 
  • The float chat button window user avatar disappeared
  •  The padding of all elements changed

 

I mean all display elements got affected just by declaring bootstrap. So I used pure CSS/Javascript instead so that I dont have to modify my existing code.



Executing Git Commnads from PHP

 This a continuation of my previous post about the new project I have in mind. I am currently using Git as my version control software and c...