Using Codeception with Laravel and subdomains - subdomain

I was hoping to use Codeception to handle a subdomain declared in Laravel 5
$router->group(array('domain' => 'admin.' . Config::get('app.host')), function()
{
Codeception appears to have an amOnSubdomain method for webdriver, but not for the Laravel 4 module.
http://codeception.com/docs/modules/WebDriver#amOnSubdomain
Is there a way to integrate this functionality with Codeception on Laravel?
I tried calling the action directly
$I->amOnAction('Auth\AuthController#showRegistrationForm');
But this throws an error
Can't be on action "Auth\AuthController#showRegistrationForm":
Symfony\Component\HttpKernel\Exception\NotFoundHttpException:
A bit confused on how to proceed.

I set an alias with the as index and it worked for me:
Route::post('/login', ['as' => 'admin.login', 'uses' => 'AuthController#postLogin']);
$I->amOnRoute('admin.login');
I also submitted an issue to the codeception repo for this method to be added. I looked into moving the method over from another module that has it already but the laravel module does some different things with it's url and history, and don't have the time at the moment to look into it more. Hopefully that method will work for you.
https://github.com/Codeception/Codeception/issues/1505

Related

Vuejs endpoint configuration

I'm really new in VueJS,
I use RxJS, Vue rx and Vue Resource in a mixin so i can make http calls and get observables back anywhere... awesome!
now i tried
subscriptions () {
return {
titles$: this.getHTTPObservable('https://jsonplaceholder.typicode.com/albums').flatMap(arr => Rx.Observable.from(arr).take(10).map(o => o.title).toArray())
}
The only thing i need now is to specify the end point of the server i am requesting in some configuration file like i would do in angular environments file. When launching the build by hand it should look like when i write
ng serve --env=dev
is there something similar?
Actually i found the answer on this page https://vuejs-templates.github.io/webpack/env.html
so, i can add any configuration variable and then call process.env.varname to get it back,
thanks
Vue.js normally works in conjunction with Webpack to achieve this.
https://v2.vuejs.org/v2/guide/deployment.html#With-Build-Tools
The DefinePlugin from Webpack is used for this. Outside of Webpack I think you are still able to use this:
https://www.npmjs.com/package/cross-env

Cakephp 3: React/zmq library namespace

I am working on on the basic tutorial on using ratchet mentioned here http://socketo.me/docs/push.
I have created a test setup for the tutorial that works flawlessly. However, when I am trying to integrate the setup with CakePHP 3 I am running into problems. The ratchet and ZMQ servers are independent just the way mentioned in the tutorial. Only the following piece of code needs to move into CakePHP 3 controllers:
$context = new ZMQContext();
$socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
$socket->connect("tcp://localhost:5555");
$socket->send(json_encode($entryData));
This code basically submits new data to ZMQ queue for forwarding to ratchet. If I place the same 4 lines in a plain PHP file outside CakePHP 3 codebase it works. When I place the same four lines inside APP\Controller\SamplesController it says the class APP\Controller\ZMQContext not found.
CakePHP 3 docs mention that vendor libraries installed via composer will be automatically available through autoloader. I have installed React\ZMQ library via following command:
php composer require react/zmq
I have tried accessing the class via following namespaces but none of them have worked:
ZMQContext ( Class 'App\Controller\ZMQContext' not found )
\ZMQContext ( Class 'App\Controller\ZMQ' not found )
React\ZMQ\ZMQContext ( Class 'App\Controller\React\ZMQ\ZMQContext' not found )
\React\ZMQ\ZMQContext ( Class 'React\ZMQ\ZMQContext' not found )
Probably missing out on some namespace concept in PHP but my understanding is that if ZMQContext is available in a normal PHP file through global namespace, then it should also be available within CakePHP 3 via \ZMQContext.
I have following questions:
How can I push data to ZMQ Queue within my CakePHP 3 APP ?
APP::path() & APP::classname() seems to work only for classes within the CakePHP 3 application. How to check path for a particular vendor library class ?
How to autoload vendor library classes correctly ? (I do not wish to require/require_once them as it will needed to be done for each controller that wants to publish data via ratchet)
Is the assumption about accessing global namespace via \CLASSNAME wrong ?
My second attempt at accessing vendor library class at \ZMQContext resolved to App\Controller\ZMQ. How is that possible when it should have attempted within root namespace ?
ZMQContext is not part of react/zmq library so does it mean it part of default php bindings for libzmq ?
This was a simple typo problem:
$context = new \ZMQContext();
$socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
$socket->connect("tcp://localhost:5555");
$socket->send(json_encode($entryData));
The second namespace specification in second line was missing.

Yii2 access to actions in new controllers

Comrades, I have had issues implementing yii2 basic but I'm yet to give up. I have successfully installed yii2, activated pretty url and created the .htaccess file in the root folder. The Home, About, Contact and Login urlswork fine.
i. I have created a new model, InstTypes with the CRUD. Why does http://localhost:8081/we#ss/instTypes/create return Not Found (#404)?
ii. I have also created a module instClients. I can access the index action in the DefaultControler. I have a model Insts with its CRUD under this modules. Why does http://localhost:8081/we#ss/instClients/insts/create return Not Found (#404)?
I tend to think that this could be due to the removal of the import and autoload from the config.
Could someone demonstrate how they've created a new model and CRUD and successfully accessed its actions?
Thanks in advance
I have created a new model, InstTypes with the CRUD. Why does
http://localhost:8081/we#ss/instTypes/create return Not Found (#404)?
You cannot access a model directly, the only way to interact with a model is via a controller which will intern interact with the model and the view. By initializing the model $model = new YourModelNmae(); or by rendering a view.
From your URL
http://localhost:8081/we#ss/instTypes/create
InstType should be your controller while create is an action under InstType
Using Yii2 Gii tool to generate a CRUD do the following : -
Generate your model
Generate your CRUD
go to
http://localhost:8081/we#ss/yourController/YourActionOnYourController
Refer to this youtube link for more detail https://www.youtube.com/watch?v=6B52-li6IgU
Happy coding :)
Just to add to the other answers, your url isn't working because it's camelCase. You need to make it hyphenated, so
http://localhost:8081/we#ss/instTypes/create
will become
http://localhost:8081/we#ss/inst-types/create
You're getting the 404 because you're trying to access instTypes, it should be inst-types.
this solved my problem. I needed to add the controllers to the controller map.

correct definition of methods Laravel 4

I have a question what would be the correct way to define methods within controllers.
I see many tutorials on using (index, show, create, store, edit, update, destroy) and in another use the following (getIndex, getShow, getCreate, postCreate, getEdit, postEdit).
the wake of this would like to know from the experts, which model to follow ?.
This is not really a Laravel problem and there is no "correct" way for a Laravel application, it's up to you, but there are some rules to follow in some cases.
Resourceful Controller Methods
The methods you listed are basically the Rails restfull ones:
index, show, create, store, edit, update, destroy
And they are automatically created by Artisan when you do:
php artisan controller:make ControllerName
Also a Laravel Restful route will expect them:
Route::resource('post', 'PostController');
RESTful Controllers
Here Laravel will try to automatically guess the kind of HTTP method your controller accepts and build all routes for you. So, if you have a route:
Route::controller('PostController');
And your PostController class having a method
public function getIndex()
{
...
}
You are telling Laravel to create a route GET to that method.
It's up to you
If you create all your routes manually, you could do:
Route::get('users', 'UsersController#usersIndex');
Pointing to
public function usersIndex()
{
...
}
And Laravel will not force you do any of those others ways.
Docs
Take a look at the docs: http://laravel.com/docs/controllers#restful-controllers
Here's some documentation about this in Rails: http://guides.rubyonrails.org/routing.html

Ruby on Rails: Adding a second custom view to a controller (Rails 3)

Rails 3:
I'm pretty new to rails and so far it's all gone really well but I'm having a little trouble understanding all of this routing stuff.
I'm now trying to add a second view to my controller but I don't want to use any of the show, edit, index, etc. actions.
I want to a custom name for the view and a custom action in the controller. Could someone please explain to me how to do this.
And also I would really like to know how to link to it from another view using the "link_to" method.
Any help is greatly appreciated!
I often use rest and for creating custom actions and views I just use routes
resources :news , :only => [:index] do
collection do
get :events
get :hot
get :last
end
member do
get :vote
end
end
so I created 3 actions for collection of resource and 1 for resource
you can run rake routes from console and see list of routes, there are predefined helpers for every route with postfix _path. example from documentation
new_geocoder_path returns /geocoder/new
edit_geocoder_path returns /geocoder/edit
geocoder_path returns /geocoder