I have created few applications in core php and now decided to move to CakePHP hoping to get better control over things. i was able to follow the cookbook blog example successfully but i understand angularjs well enough and love to work with it. i am following below article
https://github.com/hantsy/angularjs-cakephp-sample/wiki/2-rest-api
to make an api which can reply to my angularjs calls but when i call the page
http://localhost/posts.json at the end i get 404 : page not found error. not sure what is going on . I did not use the bake commands but i do have the Post model and controller well placed. Seems like there is something small thing i am missing may be in routing file . can you please help me overcoming this . Thanks for support !
pawan
Please add your cakephp folder name where your main app folder resides in url and after that it will look like this:
http://localhost/"your cakephp folder"/posts.json
Hope it helps.
Thanks
Related
I am in a weird problem.. while my Yii 1.1 application works fine on localhost,
it creates a weird url redirect loop on remote server like this
https://cart.example.com/cn/osadmin/index.php/product/cart.example.com/cn//cn/osadmin/index.php/product/cart.example.com/cn//cn/....................
Kindly note that the application is in the cn folder : https://cart.example.com/cn/
Here are some configuration settings that might be help to find out the root of the problem..
'config'=>array(
'site_url'=>'https://cart.example.com/cn',
'document_root'=>$_SERVER['DOCUMENT_ROOT'].'cn/osadmin/',
'upload_path'=>'uploads/',
'product_version'=>'',
'template_path'=>'',
'ssl'=>'https',
),
Anyone having experienced such scenario before? any clue what could be the possible reasons behind such a behaviour ?
One more strange thing.. the loop is created only when I access the controller action product/create. when I access other actions in same controller, they work fine.
I tried to remove all the code from this specific controller/action and then tried to access .. but the same problem.
I'm developing a new API using Slim Framework (v3).
I'm trying to integrate this API with Swagger UI, but when I click "Try it" button, Swagger generates the following link.
Example link:
http://localhost/api/public/contact?param1=1¶m2=2param3=3
It's correct if I don't use Slim, but a link for Slim API is like:
http://localhost/api/contact/1/2/3
What I want is that Swagger use a link to Slim API, how can I do to achieve that? I can't find a way to "translate" the link format.
I'm using Swagger-php for comments (annotations).
I hope you can help me. Thanks.
You have a couple different options.
First Swagger-ui won't show that link unless it's defined somewhere (i.e the basePath attribute) or left undefined. It sounds like there's something missing there.
Next, you can always override the basePath in your API like such:
window.swaggerUi.api.setBasePath('/api');
Which should take away the /api/public section.
It's a little difficult to debug without seeing your JSON or YAML swagger definition but those two techniques should get you over the hump.
I'm trying to learn how to develop my website using Laravel 5.
Now i'm working on the languages of the site, but I have some questions that I hope you guys might know how to solve.
I know that the Location service helps a lot when translating the site, but I want something a little more complicated. I want to put a <select></select> tag at the top of my header where the user will have the option to change to another language.
Right now, I have already created the following folders that will have all the information to be translated.
-resources
-lang
-en
messages.php
-es
messages.php
Each messages.php file has the complete directory of the information to be translated.
I know how to do this using pure php ($_SESSION) and jQuery, but I have no idea how to do this with laravel.
I would like that the website has will look like this:
/[about]
/[contact]
/en
/en/[about]
/en/[contact]
/fr
/fr/[about]
/fr/[contact]
Hope you guys help.
Thanks.
EDIT
I just found a laravel package which can help to manage this kind specific issue in the proper way.
The package name is Laravel Localization and it's pretty easy to use.
Link here
Use the directions from here: http://laravel.com/docs/master/localization
Route::get('{locale}/{page?}', function ($locale, $page == '') {
App::setLocale($locale);
// your code
});
And as for the change of the language from a drop down, just redirect the users based on their choice with java script.
I have a project where I need to mask the url.
Before: example.com/pogi/ako/
After: example.com/ako/
The application is created using codeigniter. Thoug the one found on the sub-directory have another webservice created with codeigniter as well. I tried doing some configurations I know with .htaccess and httpd.conf, but I was not able to make it run.
In the file "application/config/routes.php" add the line:
$route['ako'] = 'pogi/ako';
This will make is so that any request that comes through to example.com/ako will actually go to example.com/pogi/ako but it won't look like that.
Hope this helps!
You may want to remember how Codeigniter Handles URLs, you mentiond Sub Directory in your Question which also is Codeigniter Based Web Service !
When you are Running first Codeigniter App it will Catch your requested Url and get the related Controller and it's Method to Handle it !
Your Controllers can be nested in Sub Directory too ! also as #Ross Mentioned in his answer, this behavior can be override using Routes !
Well I am using Scaffolding concept in cakePHP for the first time, everything runs quite okay, but the problem I am facing is: after the data getting inserted into the database the page is automatically redirected to a success page.
I just want it to redirect my custom action page.
Can I do it in cakePHP Scaffoliding?
Please help me!
No! We can not add our custom redirection in scaffolding. Scaffolding is more like non-production deployment which is mostly used to give the initial idea about the framework and its feasibility towards your application.
To be precise to your question, you have to skip Scaffolding for that particular action, write saving logic and then redirect it to wherever you want.
You can bake the controller and create actions which will save your time and you can add your redirection in that.
Hope this will help.
After surfing a lot I found the idea, Here is how you can redirect to your custom action in cakePHP Scaffolding.
public function afterScaffoldSave() {
$this->redirect($this->referer());
}
afterScaffoldSave() does the trick!
hope this helps to others who has the same problem!