Download the PHP package stats4sd/laravel-r-setup without Composer

On this page you can find all versions of the php package stats4sd/laravel-r-setup. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-r-setup

Laravel R Setup

This helper package can be used to quickly scaffold an R project within the main Laravel project.

Often, we have found the need to pass particular tasks out to R, for example advanced data processing, statistical analysis, or generation of customisable reports through RMarkdown. In these cases, we want to initialise an R project within a sub-folder of the main Laravel application.

Requirements

To use this package locally, you must have R installed, and you should have installed the renv library locally (install.packages('renv') in R).

NOTE: This package does not help with installing R on your local development machine, OR on the server you deploy to. You should handle that separately!

Quick Start

To get started:

  1. require the package as a dev dependency: composer require stats4sd/laravel-r-setup --dev.
  2. Run the setup script:
    • If you want to write RMarkdown documents, run php artisan rsetup rmarkdown.
    • If you want a simpler R environment, run php artisan rsetup r.

This will create a new RStudio project with some example files in scripts/R.

Default R Setup:

The 'default' setup creates for you:

It also initialises Renv - this tool is the R equivalent to composer or npm, and it's recommended to use this to let you quickly setup any required R pacakages when you deploy your application.

You can run this example.R script to test your setup. If it is working, a user-test.csv file will be created, containing a list of users in your Laravel application database.

RMarkdown

The rmarkdown option gives you some additional files:

NOTE: If you intend to produce PDF documents with RMarkdown, you will need to ensure your deployment environment has pdflatex and pandoc installed. You also need to tell R where these applications are located, especially when running R scripts from PHP via Symfony Process.

We have found a reliable way is to add the following variables to your .env file, and reference them where needed in your R script:

  • RSTUDIO_PANDOC
  • PDFLATEX_PATH

Our init.R script for r-markdown references the PDFLATEX_PATH variable. The RSTUDIO_PANDOC one is a default variable that RMarkdown references when looking for a version of pandoc to use.

How to find your env variables

RSTUDIO_PANDOC

Use the exact output in your .env file (include the 'pandoc' on the end of the file path).

Example (from MacOS)

PDFLATEX_PATH

Use the resulting file pathway without the pdflatex. You want the path to the executable, not the executable itself.

Example (from MacOS)

Deploying Your Application

When you deploy your Laravel application with R to the server, you will need to add some additional scripts to setup the R environment. It is recommended to use Renv, which is setup automatically when you run php artisan rsetup r.

License

This repo is covered by an MIT License (MIT). You are free to copy, use, modify and distribute this package, and it would be lovely if you would credit Stats4SD where-ever you use it.


All versions of laravel-r-setup with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/console Version ^9.0|^10.0
illuminate/filesystem Version ^9.0|^10.0
illuminate/support Version ^9.0|^10.0
symfony/process Version ^6.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package stats4sd/laravel-r-setup contains the following files

Loading the files please wait ....