User Tools

Site Tools


uphp:uphp_compiler

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
uphp:uphp_compiler [2018/04/14 12:50]
jeff created
uphp:uphp_compiler [2021/09/13 05:57] (current)
Line 1: Line 1:
 ======The uPHP Compiler====== ======The uPHP Compiler======
  
-uPHP scripts are written by humans as text files. But to speed things up the Wattmon system actually executes a compiled binary version, which loads and runs much faster after the first time it is created.+uPHP scripts are written by humans as text files. But to speed things up the [[hardware:wattmons|Wattmon]] system actually executes a compiled binary version, which loads and runs much faster after the first time it is created.
  
 Mainline PHP is not a compiled language. However, uPHP is designed to run with limited memory constraints and uses a compiler to reduce requirements and speed loading and execution of scripts. Compilation is performed automatically by the firmware "in the background" as needed:  usually the programmer does not need to be concerned about this step after writing a script. Mainline PHP is not a compiled language. However, uPHP is designed to run with limited memory constraints and uses a compiler to reduce requirements and speed loading and execution of scripts. Compilation is performed automatically by the firmware "in the background" as needed:  usually the programmer does not need to be concerned about this step after writing a script.
  
-If you have spent some time looking at the files on the Wattmon you may have noticed that there are ".cgi" script files and sometimes a second version with the same name but extension ".cgc" (this is the compiled version). You might also have noticed that there are other uPHP script files that are not of type .cgi, such as .inc files (these other types are not compiled, but they can be included in a compiled script).+If you have spent some time looking at the files on the [[hardware:wattmons|Wattmon]] you may have noticed that there are ".cgi" script files and sometimes a second version with the same name but extension ".cgc" (this is the 'cached' or 'compiledversion). You might also have noticed that there are other uPHP script files that are not of type .cgi, such as .inc files (these other types are not compiled, but they can be included in a compiled script).
  
-This page provides some practical information on when and how the uPHP Compiler works, of interest to those who are customizing the Wattmon, writing their own scripts or modifying the scripts provided with the Wattmon OS.+This page provides some practical information on when and how the uPHP Compiler works, of interest to those who are customizing the [[hardware:wattmons|Wattmon]], writing their own scripts or modifying the scripts provided with the Wattmon OS.
  
 ====When Does the Firmware Compile a Script?==== ====When Does the Firmware Compile a Script?====
Line 79: Line 79:
   * If changes are made to any included files in the .cgi script (see function [[.functions:include]]).   * If changes are made to any included files in the .cgi script (see function [[.functions:include]]).
  
-In these situations, the system will run an existing .cgc without examining the .cgi text file or included file(s) for changes, so be sure to delete the corresponding .cgc file at the same time: I learned this "the hard way" when edited an included file and could not figure out why my changes weren't working!+In these situations, the system will run an existing .cgc without examining the .cgi text file or included file(s) for changes, so be sure to delete the corresponding .cgc file at the same time. (Note from the author of this page: I learned this "the hard way" because didn'have this documentation at the time, which led to the creation of this page.) 
 + 
 +In most cases, an easy way to delete compiled versions is to use the dropdown menu option "Clear Cache" (in the header of most displayed pages on the [[hardware:wattmons|Wattmon]]): 
 + 
 +{{ 20180420_130046_screenshot.jpg?600 |Clear Cache}} 
 + 
 +"Clear Cache" deletes all .cgc files in the "/" (root), "/app", "/scripts", "/package" and "/shell" folders (if the script you are working with is located somewhere else you will need to find and delete the .cgc file manually).
  
 ====Also See==== ====Also See====
uphp/uphp_compiler.1523710255.txt.gz · Last modified: 2021/09/13 05:56 (external edit)