Installing Yii 2 demo application - php

i am trying to install yii 2 and to run the basic or advanced application.
i have tried the steps given here Setting up preview of Yii2 to do this.
the steps i followed,
1 - Installed the composer
2 - Use composer to install the app alongwith dependencies(Yii): php path/to/composer.phar create-project --stability=dev yiisoft/yii2-app-basic my_yii2_trial
3 - Access app from http://localhost/my_yii2_trial/web
The problem is, i am getting this syntax error.
Parse error: syntax error, unexpected '[', expecting ')' in D:\xampp\htdocs\my_yii2_trial\vendor\yiisoft\yii2\yii\Yii.php on line 25
can any body help to resolver this issue pls

Yii2 has started using PHP 5.4's Short array syntax. Your error creeps up because of:
spl_autoload_register(['Yii', 'autoload'], true, true);
in Yii.php, which is the new short array syntax. As you have already figured out, you need to install PHP 5.4 now to run Yii2 apps.
The commit which made the changes to short array syntax.
The docs and composer details that have been changed.
The discussion where the decision to move to PHP 5.4 was made.
As Yii2 is still in heavy development, its requirements are also changing. So be sure to read the readme thoroughly before installing.
See also the Backward Incompatible changes list for PHP 5.4, to make changes to your existing code.

Install PHP 5.4 to resolve this issue.

Yii2 Installation Following command:
(1) First install Composer (LINUX):
Locally:
curl -sS https://getcomposer.org/installer | php
OR
(1) First install Composer (WINDOWS):
C:\Users\username>cd C:\bin
C:\bin>php -r "readfile('https://getcomposer.org/installer');" | php
Note: If the above fails due to readfile, use the http url or enable php_openssl.dll in php.ini
C:\bin>echo #php "%~dp0composer.phar" %>composer.bat*
C:\Users\username>composer -V
Composer version 27d8904
(2) Yii2 framework online downloads:
Basic App:
php composer.phar create-project yiisoft/yii2-app-basic basic 2.0.0-beta
Advanced App:
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-beta
(3) Other App Settings Command:
php init
php yii migrate

Here is command lines to install yii2 on ubuntu:
cd /var/www
/var/www$ ls
/var/www$ cd myyii2
/var/www/myyii2$ ls
/var/www/myyii2$ ls -al
/var/www/myyii2$ ls
/var/www/myyii2$ php init
/* Your choice [0-1, or "q" to quit] 0*/
choose 0 for developemnt and type yes
php yii migrate (/var/www/myyii2$ php yii migrate)
Before this command need to download advance setup like [yii-advanced-app-2.0.7.tgz]

Related

Not able to install symfony on windows

Hello I am trying to install symfony on Windows. I had follow the all require steps for it but it end up with below message.
[RuntimeException]
Symfony can't be installed because the downloaded package is corrupted.
To solve this issue, try executing this command again:
Symfony new demo 3.2.8
When i tried above command it says :
'symfony' is not recognized as an internal or external command,
operable program or batch file.
I have try to reinstall composer and Symfony package both but it does not resolve the issue. It stays the same issue again.
Please help me how can I install it on Windows.
You are required to make it run through PHP as its a script file.
This gets the installer (which it looks like you have already)
php -r "readfile('https://symfony.com/installer');" > symfony
Then php symfony new demo 3.2.8 (asuming if php is in path otherwise you have to specify the php.exe path too)
For the full details see http://symfony.com/doc/current/setup.html
Regards
forget about that installer use composer from command line
composer create-project symfony/framework-standard-edition my_project_name
BTW i don't know what server you are using (wamp/xamp etc), i recomending this
https://laragon.org/
it have composer and all tools that you need to start with symfony

create new web application in yii 2 advanced

I just started to try yii php framework, i have followed all the installation tutorial and I can run the yii framework, but i got stuck when I wanted to create a new web application by using command prompt.
the following command is like
cd c:\xampp\pathtoyii\framework
then
yiic webapp newWebAPP
the problem is in my yii folder doesn't contain framework folder and yiic file that i must write in the following command. anyone know this issue?
here is my yii folder root
no framework folder there.
actually, I need a path like this
and this is the framework folder.
is there any different in new version of yii that I installed?
So the issue here is you are mixing Yii1 and Yii2. If the tutorial you are reading references "yiic", that is Yii1, not Yii2. The framework folder you show also is from Yii1.
I'm not sure if you are trying to write a Yii1 or Yii2 app. If Yii2, check out the instructions for setting up a new app here: http://www.yiiframework.com/doc-2.0/guide-start-installation.html If Yii1, here: http://www.yiiframework.com/doc/guide/1.1/en/quickstart.installation
They are very similar, but are fundamentally different frameworks as Yii2 is NOT backwards compatible.
Read the installation guide!
First, you must install a composer.
Than, require asset plugin:
composer global require "fxp/composer-asset-plugin:~1.1.1"
and install project:
composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-application
Yii2 Installation Following command:
(1) First install Composer (LINUX):
Locally:
curl -sS https://getcomposer.org/installer | php
OR
(1) First install Composer (WINDOWS):
C:\Users\username>cd C:\bin
C:\bin>php -r "readfile('https://getcomposer.org/installer');" | php
Note: If the above fails due to readfile, use the http url or enable php_openssl.dll in php.ini
C:\bin>echo #php "%~dp0composer.phar" %*>composer.bat
C:\Users\username>composer -V
Composer version 27d8904
(2) Yii2 framework online downloads:
Basic App:
php composer.phar create-project yiisoft/yii2-app-basic basic 2.0.0-beta
Advanced App:
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-beta
(3) Other App Settings Command:
php init
php yii migrate

zftool not behaving as expected

I have a hosting service in linux, where I’m trying to develop an app on zend framework 2. I want to use zftool but regardless which zftool command I run, I get always the HTML of the home page.
I’ll really appreciate any help.
Here are the steps to reproduce:
1 - I installed composer
>curl -s https://getcomposer.org/installer | php
2 - I installed the Skeleton MVC application
>php composer.phar create-project -sdev --repository-url="https://packages.zendframework.com" zendframework/skeleton-application ./hmzf
3 - Brought Composer up to date
>php composer.phar self-update
4 - Install ZFTool
>php composer.phar require zendframework/zftool:dev-master
5 - Createa symbolic link to invoke it from my project directory
>ln -s ./vendor/zendframework/zftool/zf.php zf.php
6 - Run zf.php to get the list of modules and what I get in return is the html of the home page of the skeleton app:
> php zf.php modules
I found the issue. I had to use php-cli to invoke zf.php. So instead of issuing:
php zf.php modules
which will echo the zend app home page HTML to the console, I had to issue:
php5.4-cli zf.php modules
and I've got the right response from the tool, which is:
Modules installed:
Application

create symfony project using the symfony installer

i used to to use composer to create a new symfony project like so
composer create-project symfony/symfony-standard-edition SymfonyProjectDir 2.5.*
but know when i want to use the symfony installer i use the command
symfony new SymfonyProjectDir 2.5.*
or
symfony new SymfonyProjectDir 2.5
but i get this error
[RuntimeException]
The Symfony version should be 2.N.M, where N = 0..9 and M = 0..99
new directory [version]
how can i tel that i want to use the version 2.5 including the last updates from symfony like i used to with composer?
There is no reason to have the latest minor version of an version. You start developing with the latest version and then you should freeze it until there is a reason to update.
If you don't care, clone the git repo, grep your tag and create your project with it.
You can try this, it worked for me:
Symfony Installation and Project Creation
Or just open command line and execute these commands:
for (linux/mac)
sudo curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony
sudo chmod a+x /usr/local/bin/symfony
symfony new SymfonyProjectDir 2.5
The version will be the most recent version in 2.5, as you want
Last answer here is from 2016 so if you end up here somehow in 2019 the solution is much easier!
First make sure you are using a php version of 7.1 or higher.
Check if you have composer installed and if you don't just follow this easy documentation: Download/Install Composer
Now you are all set, go to the directory where you want your symfony project be stored and enter the command composer create-project symfony/website-skeleton my-project. This will create your first structure in symfony 4!
Now you just enter your project directory and type php bin/console server:run on your terminal and you are done.
You can import repositories from git too starting git init from the same project folder.
First time with Symfony? Follow this tutorial for a first controller/view: Introduction to symfony4
Hope this if somehow usefull to anyone, i'm just trying to give something back to this community that has given me so much.
Please try with it:
composer create-project symfony/framework-standard-edition SymfonyProjectDir/ 3.0.7
It should work. Maybe your forgot the last slash...

Composer install cant find composer.json

I am trying to just install composer, I am on mac osx. I have done it before using the terminal lines from their site and it worked just fine. I got a clean install on my mac now, and it won't install properly.
I tried to:
cd ~
curl -sS https://getcomposer.org/installer | php
and and:
cd /Applciations/MAMP/htdocs
curl -sS https://getcomposer.org/installer | php
and neither works. (I saw a post saying I should cd to a directory before trying to install it. But no matter what, I keep hitting this error:
Composer could not find a composer.json file in /Applications/MAMP/htdocs
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section
when trying to install composer.
I think your question arises from a slight misunderstanding. Composer installs itself when you run the script provided on their Web site. No additional work to install Composer is necessary.
$ php composer.phar install is used to install packages with Composer, which are almost always listed in a JSON file named composer.json. Without this file, Composer doesn't know which packages to install and fails.
See "Declaring Dependencies" in Composer's Getting Started guide for how to generate a composer.json for your project.
In my case, I had a deprecated error being output from PHP. Apparently that causes composer to fail detecting the composer.json file.

Categories