I have a simple website on Laravel with different types of entries and categories.
I need to create documentation for him.
I tried to install phpDocumentor, but it is not installed on Laravel latest version.
Also I should clarify that this is not the API of the project a simple website.
What other solutions do you have for automatically generating documentation?
If you want to create documentation for routes, you can try laravel-routes.
This package can be installed with composer with the next command:
composer require gussrw/laravel-routes
You can generate the HTML file from the console with the next artisan command.
php artisan route:docs
This command creates an HTML file in Project/docs.
Route description
The description is optional, but if you want to add them create a PHP comment over each route in the web.php file with #description.
/**
* #description Show the home page of the site
*/
Route::get('/home', 'HomeController#index') -> name('home.index');
Resources routes
The descriptions in the resource type routes are identified by their method in the controller.
/**
* #index Show the main view
* #create Show the view to create a photo
* #store Save a photo in database
* #edit Show the view to edit a photo
* #update Update photo data in database
* #destroy Delete a photo in database
*/
Route::resource('photos', 'PhotoController');
Params
Routes params are defined with #param name Description, you can use #param in resource type routes.
/**
* #description Download photo with the photo id.
* #param id ID of the photo in database
*/
Route::get('/photo/{id}/download', 'PhotoController#download');
Related
Sorry for this long post I don't have any other way to describe it in short.
I have two Laravel application which are hosted in two subdomains of the same domain. One is
form.example.com another is dashboard.example.com.
The Dashboard app sends a http request to the Form app to get some JSON data. And the code it uses to send the request is like this:
$url = "https://form.example.com/api/v2/get/orders/" . urlencode($log->lastpull);
$client = new \GuzzleHttp\Client();
$request = $client->request('GET', $url);
$json = $request->getBody();
$objects = (json_decode($json));
Now the problem is that Dashboard app sometimes get a blank JSON or some error message in return from the Form app when this request is made.
However the same code works file in the localhost and when I look up the URL (https://form.example.com/api/v2/get/orders/) I get a valid JSON object. Which indicates that Form app is fine.
The error message I talked about I get from the Form app as a response for the HTTP request is this:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dbl5qxvxfrl9tl.products' doesn't exist (SQL: select * from `products` order by `index` asc)
The problem with this error message is that the database it mentions 'dbl5qxvxfrl9tl' belongs to the Dashboard app! The app which is making the request.
I have no idea why the Form app is looking for its table on the Dashboard app's database. It only occurs when I host the Dashboard app on my shared hosting's server. In localhost it works fine.
I tried to export the stack trace from the error page but for some reason it was not letting me to export. So I have saved the html page:
drive.google.com/file/d/1elbJhv4BpDNlxC2Ji_463dDLndjzjbm6/view?usp=sharing
(I have replaced the domain name in this html file for privacy reasons)
As user #apokryfos commented on the main post, solution to this problem is this:
If these are two separate Laravel apps in different paths then you can also try running php artisan config:cache on both of them to generate a cache for the config so it doesn't read environment variables anymore (in case there's some cross-over)
I am working on an integration between my laravel 5.2 app and MailChimp. I have downloaded and installed the spatie/newsletter https://github.com/spatie/laravel-newsletter but form some reasons the integration doesn't work meaning a contact is not created in mailchimp. I have added the providers and aliases in the config/app.php file, config/larave-newsletter.php file contain the proper settings
/*
* The api key of a MailChimp account. You can find yours here:
* https://us10.admin.mailchimp.com/account/api-key-popup/
*/
'apiKey' => env('MAILCHIMP_APIKEY'),
/*
* When not specifying a listname in the various methods, use the list with this name
*/
'defaultListName' => 'ListName',
/*
* Here you can define properties of the lists you want to
* send campaigns.
*/
'lists' => [
/*
* This key is used to identify this list. It can be used
* in the various methods provided by this package.
*
* You can set it to any string you want and you can add
* as many lists as you want.
*/
'subscribers' => [
/*
* A mail chimp list id. Check the mailchimp docs if you don't know
* how to get this value:
* http://kb.mailchimp.com/lists/managing-subscribers/find-your-list-id
*/
'id' => env('MAILCHIMP_LIST_ID'),
],
],
/*
* If you're having trouble with https connections, set this to false.
*/
'ssl' => true,
My controller contains the following:
Newsletter::subscribe($user->email, ['FNAME'=>$user->first_name, 'LNAME'=>$user->last_name]);
The strange thing is when I use tinker to add a contact, it does work
Newsletter::subscribe($user->email, ["FNAME"=>$user->first_name, "LNAME"=>$u
ser->last_name]);
Is there a workaround for this issue and how can I solve it? Thanks
I was able to fix the issue by changing the default ssl setting from true to false. It appears my server was having some issues with https connections.
Should one experience a similar issue, they can try setting 'ssl'=>false in the config/laravel-newsletter.php file maybe it'll fix their issue.
I solved the same problem
run this commandes :
composer install
php artisan config:cache
php artisan route:cache
I was able to get this working by setting 'endpoint' to null instead of an empty string (as specified in the install instructions) in config/newsletter.php
I am new in laravel framework. I install the Auth Class in my project. So when I login in my project it goes to dashboard but url is ('/home'). I want to change this path and after login I want that it goes ('/dashboard'). For that jobs, which file I want to change? I have find 4 file where /home is decleared. Thats are web.php, LoginController.php, HomeController.php, RedirectIfAuthenticated.php. Which file I will change? or any more file there?
Web.php file
homeController.php file
loginController.php file
redirectIfAuthenticated.php file
There's now an easier way to do this in Laravel 6.X.
Simply change the constant in theapp/Providers/RouteServiceProvider.php file.
/**
* The path to the "home" route for your application.
*
* #var string
*/
public const HOME = '/new-url';
After that, change your route in your routes/web.php file.
Route::get('/new-url', 'Controller#method');
// If you don't want to use the HomeController, be sure to include the auth middleware.
Route::get('/new-url', 'Controller#method')->middleware('auth');
You can delete the HomeController if you're not using it in your route, won't cause any issues.
You have to add the redirectTo property to the LoginController, RegisterController, and ResetPasswordController files:
protected $redirectTo = '/';
It is well explained in the Laravel documentation:
https://laravel.com/docs/5.5/authentication#authentication-quickstart
I have come across this before... change the protected
$redirecto = /home to / in the login controller, then got to routes->web and change the Route::get('/home') to Route::get('/')->name('dashboard')
or you can just change $redirecto = "/dashboard" in the login controller and make sure that you create/update a path in the routes.
Hope it helps.
In a Laravel 4 installation, Using Jeffrey Way's Laravel 4 Generators, I set up a 'tweet' resource, using the scaffolding command from his example:
php artisan generate:scaffold tweet --fields="author:string, body:text"
This generated the model, view, controller, migration and routing information for the tweet type. After migrating the database, visiting http://localhost:8000/tweets works fine, and shows the expected content.
The contents of the routes.php file at this point is:
Route::resource('tweets', 'TweetsController');
Now I would like to move the url for tweets up one level into admin/tweets, so the above url should become: http://localhost:8000/admin/tweets. Please note that I am not treating 'Admin' as a resource, but instead just want to add it for hypothetical organizational purposes.
Changing the routes.php file to:
Route::resource('admin/tweets', 'TweetsController');
Does not work, and displays the following error:
Unable to generate a URL for the named route "tweets.create" as such route does not exist.
Similarly when using the following:
Route::group(array('prefix' => 'admin'), function() {
Route::resource('tweets', 'TweetsController');
});
As was suggested in this stackoverflow question.
Using php artisan routes reveals that the named routes also now have admin prefixed to them, turning tweets.create into admin.tweets.create.
Why is the error saying that it cannot find tweets.create? shouldn't that automatically be resolved (judging by the routes table), to use admin.tweets.create?
How can I change my routing so that this error no longer occurs?
I just tested with new resource controller and it works fine for me.
The problem is not with the Route, its with the named routes used in your application.
check your view files there are link to route like link_to_route('tweets.create', 'Add new tweet'), this is creating the error because when you add admin as prefix tweets.create doesn't exists so change it to admin.tweets.create every where, in your controller also where ever named route is used.
I'm receiving "500 - Internal server error." on the domain of my WordPress site.
Installed WordPress locally through Web Platform Installer in IIS (Win7).
Developed a landing page in Firefox locally, then FTP'd the site to the web server (which also hosts multiple sites from various domains).
Used MySQL Workbench 5.2 CE to create and export the database, which was also uploaded onto the server. Database was tested.
I've read all the posts relating to "Wordpress" and "500 - Internal server error.", none have helped.
I've tried creating the .htaccess file with the following contained:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
All file paths in IIS are correct.
Below is the wp-config.php file
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {#link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
* installation. You don't have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* #package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'zxcvb');
/** MySQL database username */
define('DB_USER', 'zxcvb');
/** MySQL database password */
define('DB_PASSWORD', 'zxcvb');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
/**##+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {#link https://api.wordpress.org/secret-key/1.1 /salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* #since 2.6.0
*/
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');
/**##-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* WordPress Localized Language, defaults to English.
*
* Change this to localize WordPress. A corresponding MO file for the chosen
* language must be installed to wp-content/languages. For example, install
* de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
* language support.
*/
define('WPLANG', '');
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define('WP_DEBUG', false);
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
Please help!
Thanks
Wordpress stores some domain-specific settings in its options table. If you did the installation locally and then exported it to an external hosting provider it is very likely that those settings are still misconfigured in your WordPress DB and setup for a local installation.
Check the options table in WordPress (add your prefix as needed). Look through the rows for those options that make references to your local installation (its URL or resources) and update them with the corresponding values appropriate for your hosting.
In particular, I'd suggest you check the rows with the following option_names:
siteurl
home
Once those are setup correctly you should be able to access WP's installation and fix others (like image URLs and some other things like that) from its admin interface.