Create and download CSV in PHP
Consider the possibility of quickly creating a CSV file with automatic file download. Consider the formation, separators and header for the ability to download the file.
$_SERVER['DOCUMENT_ROOT'] will not be available in the CLI . The web server defines the document root. In the CLI , you are not using a web server, so there is no document root.
You can try to rely on environment variables, assuming they are set by your shell. For example, $_SERVER['PWD'] represents the current directory and $_SERVER['HOME'] represents the user's home directory.
But this example with PWD is irrelevant if you run the script from a different directory than the executable file. That is, PWD reflects the directory in which you are at the time of launch.
I will give my example , which allows you to calculate the directory of the file being launched:
<?php
$self = pathinfo(__FILE__, PATHINFO_BASENAME);
$document_root = rtrim(str_replace($self, '', __FILE__), '/');
$document_root will contain the directory where the executable file is located.
Consider the possibility of quickly creating a CSV file with automatic file download. Consider the formation, separators and header for the ability to download the file.
Latest templates from ImageCMS 4.12, authorization is required to download.
Consider options for popular options for storing goods in a shopping cart in an online store. Let's outline the pros and cons of such storage. Consider options for long-term storage of the basket.
Creating a key for imageCMS 4.9-4.12.1 Pro and Pre. You must be logged in to receive it.
After developing any tool in PHP, the question becomes how resourceful the created code is and what elements it still affects. Let's take a look at xhprof installation, configuration, and how to work with xhprof.
Let's analyze the possibility of combining conditions in a query by groups in Propel. Consider an example of filtering by fields using ->condition() and ->combine().
Faced the problem of authorization 1s on the site. For some reason, the server did not accept the PHP_AUTH_USER and PHP_AUTH_PW parameters from it. Let's take a closer look at the solution and bypassing these parameters in $_SERVER .
The purpose of the article was to join (join) a table not declared in the schema (schema.xml) in propel2. Apparently a rare case or simply not enough documentation for this Propel ORM.