Skip to content

Installation & Usage

Semyon "xRef edited this page Sep 29, 2023 · 18 revisions

xRefCore is a simple framework to create PHP CLI applications. It has some tools which could may help you to create your application, such as multithreading, HTTP-server, asynchronous tasks, pseudo GUI and etc.
xRefCoreCompiler builds the application from your source code.

System requirements

  • PHP 7.4 or above
  • Installed and enabled sockets extension
  • Parameter phar.readonly is Off

Installation

Download script-installer (install.ps1 for Windows (PowerShell), install.sh for Linux) from repository. Run script. It will download, install and configure xRefCoreCompiler.

Probably issues:

  • PHP was not found. It means that script can't recognize php command.

    Solution for Windows
    Add php.exe to your Path variable. If you don't know how, google for "windows add exe to path variable". Then open cmd.exe and input php -v. If you did everything right, you will see something like that:

    PHP 7.4.11 (cli) (built: Sep 29 2020 13:18:06) ( ZTS Visual C++ 2017 x64 )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
    

    Solution for Linux
    99% that there is no /usr/bin/php binary file. You have to create symlink /usr/bin/php to /path/to/your/php or just move it. Then check it php -v

  • I have two or more installed PHP version, but script is using default PHP

    Solution for Windows
    No solution yet.

    Solution for Linux
    Just run installation script and specify desired PHP-version. Example: ./install.sh --php /usr/bin/php7.4.

  • I can't use xrefcore-compiler --prepare-project on Windows

    Explanation
    Because of a Windows security policy, you are not allowed to create symlinks in non-administrator mode. xRefCoreCompiler creates a symblink to the xRefCore API in your PhpStorm project for prompts. If you are not using PhpStorm, but, for example, you are using a simple text editor, you may not read the solution to the problem.

    Solution
    There is a three ways:
    1. If you're using PhpStorm, just launch it with admin privileges.
    2. Allow users to create symlinks in Windows Security Policy Settings. But unfortunately, this will not have an effect on administrative accounts. They will still be able to create character links only in Administrator mode
    3. Add flag to run php.exe always in Admin-mode via regedit. Google for windows 10 run exe always as administrator regedit.
    4. Create in project a batch file, write to it this:

    cd C:\path\to\your\projects\ProjectName
    xrefcore-compiler --prepare-project
    

    ...and run it as Administrator.

  • I run xrefcore-compiler --prepare-project, but it creates an invalid symlink.
    Go to your home directory. If there is no .xRefCoreCompiler folder (pay attention on dot in folder name), then create it, run xrefcore-compiler --configure. Go to your project, delete an invalid symlink and try xrefcore-compiler --prepare-project again.

Usage

  1. Create PhpStorm project (in this tutorial we're created project MyFirstApp)
  2. Open PhpStorm Terminal and run this command xrefcore-compiler --prepare-project (in Windows you may have some issues. Check above). It will create Main class and symlink to xRefCore API. RUN THIS COMMAND ONLY ONCE WHEN YOUR PROJECT JUST CREATED!!!
  3. Now in your project is another one folder MyFirstApp. We need to move into it. Input cd MyFirstApp in your terminal.
  4. Start your coding in Program/Main.php
  5. Build your application. Use xrefcore-compiler --build. At first build, you have to fill application data, then save it to your project

https://www.youtube.com/watch?v=7ymvlF0MSYA

Review xRefCore documentation

on xrefcore.ru

Examples

https://github.com/mamayadesu/xRefCore/wiki/xRefCore-Examples

Clone this wiki locally