Differences

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

Link to this comparison view

Both sides previous revision Previous revision
magicapp [2017/07/19 05:49]
aducomadmin
magicapp [2018/12/30 19:29] (current)
aducomadmin
Line 1: Line 1:
 ====== Magic around $app, $$ and components ====== ====== Magic around $app, $$ and components ======
  
-The $app variable in the php applications is the '​magic'​ variable that contains references to almost anything in your application. If you create your applications all your components will be assigned unique names. In general it will use a prefix of the componenttype ​with a sequence number. I.e. for a regular ​edit field you would get //edit_1, edit_2, edit_…//. But that name could be re-used in other php applications. As long as these applications run stand alone, nothing is at hand, but if you are starting to use building blocks it is very likely to come across duplicate id's. Since html does not support namespaces, PHsPeed takes care of that and will prefix all component variables with its module name. So '​edit_1'​ might become something like:// '​mymodule_edit_1'​. //To access the value of this component you would get:+The $app variable in the PHP applications is the '​magic'​ variable that contains references to almost anything in your application. If you create your applicationsall your components will be assigned unique names. In generalit will use a prefix of the component type with a sequence number. I.e.for a normal ​edit field you would get //edit_1, edit_2, edit_…//. But that name could be re-used in other PHP applications. As long as these applications ​will run standalonethen nothing is at hand, but if you are starting to use building blocksit is very likely to come across duplicate id's. Since HTML does not support namespaces, PHsPeed takes care of that and will prefix all component variables with its module name. So '​edit_1'​ might become something like:// '​mymodule_edit_1'​. //To access the value of this component you would get:
 <​code>​ <​code>​
 $myvar = $app→mymodule_edit_1→value;​ $myvar = $app→mymodule_edit_1→value;​
 </​code>​ </​code>​
  
-To access this variable in you event code, you have to continuously ​think about the given name in the IDE and it's '​real'​ name in the final php code. To prevent that, PHsPeed uses a short notation for the $app→mymodule_ part. By typing $$ as the prefix for your application,​ PHsPeed will automaticall ​prefix this variable. So you can type:+To access this variable in your event code, you have to think about the given name in the IDE continuously, ​and it'​s ​the '​real'​ name in the final PHP code. To prevent that, PHsPeed uses a short notation for the $app→mymodule_ part. By typing $$ as the prefix for your application,​ PHsPeed will automatically ​prefix this variable. So you can type:
  
 <​code>​ <​code>​
Line 12: Line 12:
 </​code>​ </​code>​
  
-Which has the same effect, but is more easy to use. This notation is also accepted by the php pre-compiler in the IDE. So if you precompile your event code to avoid syntax errors after generation, you will not get errors on these statements.+Which has the same effect, but is more comfortable ​to use. The PHP pre-compiler ​also accepts this notation ​in the IDE. So if you precompile your event code to avoid syntax errors after generation, you will not get errors on these statements.
  
-In a lot of situations you will need to $this→ your variable. To speedup ​typing this, there is a code-completion action in the PHP editor that will replace $$ by $this. This can be forced using shift-space as soon as you have typed $$.+In a lot of situationsyou will need to $this→ your variable. To speed up typing this, there is a code-completion action in the PHP editor that will replace $$ by $this. This can be forced using shift-space as soon as you have typed $$.
  
-As an example of above, the next code will logon a user, using plain sql. PHsPeed uses PDO and prepared code for security reasons.+As an example of above, the next code will logon a user, using plain SQL. PHsPeed uses PDO and prepared ​the code for security reasons.
  
 <​code>​ <​code>​