PHP code example of heldtogether / venice-php

1. Go to this page and download the library: Download heldtogether/venice-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

heldtogether / venice-php example snippets



	$container->singleton('Venice\Manager', function(){
		$factory = new Venice\Factory();
		$config = new Venice\Configs\JSONFileConfig($factory);
		$config->setFilename('/path/to/config/file.json');
		$manager = new Venice\Manager();
		$manager->addConfig($config);
		return $manager;
	});

	$container->singleton('Venice\Bucketer', function(){
		$session = new Venice\Sessions\CookieSession();
		$return new Venice\Bucketer($session);
	});

	$container->bind(
		'Venice\Interfaces\SessionInterface',
		'Venice\Sessions\CookieSession'
	);


	/**
	 * Basic Controller
	 */
	 class Controller {

		/**
		 * @var Venice\Manager
		 */
		protected $features;

		/**
		 * Construct
		 *
		 * @param Venice\Manager $features
		 * @return void
		 */
		public function __construct(Venice\Manager $features) {

			$this->features = $features;

		}

		/**
		 * Handle the index route.
		 */
		public function index() {

			if ($this->features->get('feature-name')->active()) {

				// Do something

			}

		}

	}

	/**
	 * Check if the Feature is active
	 *
	 * @return bool
	 */
	public function active();

	/**
	 * Set the active state of the feature
	 *
	 * @param bool $active
	 * @return void
	 */
	public function setActive($active)

	/**
	 * Check if the Feature is active
	 *
	 * @return bool
	 */
	public function active();

	/**
	 * Get the start time of the Feature
	 *
	 * @return Carbon\Carbon
	 */
	public function startTime();

	/**
	 * Set the time the Feature should be active
	 *
	 * @param string $start_time
	 * @return void
	 */
	public function setStartTime($start_time);

	/**
	 * Get the end time of the Feature
	 *
	 * @return Carbon\Carbon
	 */
	public function endTime();

	/**
	 * Set the time the Feature should become inactive
	 *
	 * @param string $end_time
	 * @return void
	 */
	public function setEndTime($end_time);

	/**
	 * Check if the Feature is active
	 *
	 * @return bool
	 */
	public function active();

	/**
	 * Get the variant for the current session
	 *
	 * @return string
	 */
	public function variant();
javascript
	{
		'feature-name': {
			'type': 'timed',
			'start_time': '2015-10-06 12:30:20',
			'end_time': '2015-10-10 12:30:20'
		}
	}