Manually installing/integrating a composer package - laravel

I tried installing this composer module on my Laravel app https://github.com/alihesari/laravel-social-auto-posting but im facing some issues. Im avoiding composer since it requires me to update my Laravel version which will break things (im runnin under 5.1.9).
Steps that I took so far:
1) wget https://github.com/alihesari/laravel-social-auto-posting/archive/master.zip - inside htdocs directory
2) unzipped master.zip and renamed folders. Moved folders inside /vendor/ folder under this structure:
/vendor/toolkito/larasap/ - This folder contains the src subfolder as shown in the repo.
3) Added this reference in \vendor\composer\autoload_namespaces.php and in \vendor\composer\autoload_psr4.php: 'Toolkito\\Larasap' => array($vendorDir . '/toolkito/larasap/src'),
4) Configured my secret keys in the config file, for the proper social media connection
5) Added use Toolkito\Larasap\SendTo; in the main controller, as per repo's instructions
6) Added SendTo::Twitter('Hello, I\'m testing Laravel social auto posting'); to a function that I use and ended up in this error:
FatalThrowableError in HomeController.php line 47:
Fatal error: Class 'Toolkito\Larasap\SendTo' not found
I also tried use Vendor\Toolkito\Larasap\SendTo; in step 5, and ended up with the same error message.
Any suggestions please?

Related

Create own laravel package

I try to create own laravel package.
I created package folder in my project in root directory.
Than created simplexi/greetr/src folders in package.
I added to autoload "Simplexi\Greetr\": "package/simplexi/greetr/src" in composer.json in main project, and used command composer dump-autoload.
Than in src folder I created RiakServiceProvider, added this provider to config=>app.php to providers array.
Then in boot method I added next code:
$this->publishes([__DIR__ . '../config/myconf.php' => config_path() . '/']);
And executed next command:
php artisan vendor:publish --provider="\Simplexi\Greetr\RiakServiceProvider"
Than I got Publishing complete.
But file myconf.php didn't copy to app/config.
Also I checked file myconf.php in my package/simplexi/greetr/config folder and it exists.
Can anyone tell me what the problem might be?
publishes() expect two parameters. Try something like this:
$this->publishes([
__DIR__.'/../config/myconf.php' => config_path('myconf.php'),
], 'config');

Unable to generate resources using laravel-code-generator in Laravel 5.8

I created a fresh Laravel project v5.8. Then installed the latest version of the Laravel Code Generator (2.3) but I'm unable to generate resources. I've read your release notes for 2.3 and I'm not seeing where I'm making a mistake on the installation or the commands I keep the output below:
php artisan create:scaffold Test generates the output below:
Exception : The file
resources/laravel-code-generator/sources/tests.json was not found!
at /Users/Sites/Laravel/lms/vendor/crestapps/laravel-code-generator/src/Models/Resource.php:686
682| {
683| $fileFullname = Config::getResourceFilePath($filename);
684|
685| if (!File::exists($fileFullname)) {
> 686| throw new Exception('The file ' . $fileFullname . ' was not found!');
687| }
688|
689| return File::get($fileFullname);
690| }
Exception trace:
1 CrestApps\CodeGenerator\Models\Resource::jsonFileContent("tests.json")
/Users/Sites/Laravel/lms/vendor/crestapps/laravel-code-generator/src/Models/Resource.php:549
2 CrestApps\CodeGenerator\Models\Resource::fromFile("tests.json", "CrestApps")
/Users/Sites/Laravel/lms/vendor/crestapps/laravel-code-generator/src/Commands/Framework/CreateScaffoldCommand.php:70
Please use the argument -v to see more details.
I'm getting a similar output when trying to create resources from a database table. I'm using the php artisan resource-file:from-database [model-name] command.
I read online that it may have to do with the Laravel storage folder not having the correct permissions but I've tried that and it didn't work. Cleared and config the cache, composer dump-autoload, etc... But nothing has worked.
I'm also noticing that the generator does not publish the configuration file on your sample video on your website. I have tried to publish the config file using the vendor:publish command but it generates a somewhat empty file, only has this option: 'files_upload_path' => 'uploads'. The folder for the generator located inside the resources folder does not contain a config file.

View [layouts.app] not found in laravel

I have created an application in laravel using appzcoder crud-generator plug-in. i have done everything accordingly but i am getting the above mentioned error. I have a folder named layouts in views folder and this folder has app.stub in it. but when i run the project it gives the following error
View [layouts.app] not found. (View:C:\wamp64\www\myProject\resources\views\admin\items\index.blade.php)
make sure you have run below code if not run it will create layout.app path
or manually create view/layout/app.php
php artisan vendor:publish --provider="Appzcoder\CrudGenerator\CrudGeneratorServiceProvider"

API Class not found using Composer

I am new to using composer, I have it installed, created composer.json file. Installed bigcommerce api using these instructions: https://github.com/bigcommerce/bigcommerce-api-php
When I try to run "use Bigcommerce\Api\Client as Bigcommerce" I am getting error class not found.
I am using localhost and my file structure is:
testsite
src-> contains all classes including Client.php
vendor -> bigcommerce -> api -> the api files,
api.php -> my test file trying to connect to api
I have not changed any composer files, I have looked into autoloading. As I said before it is first time using composer.
Please read the documentation of Composer here: https://getcomposer.org/doc/00-intro.md Pay attention to the last couple of paragraphs, "Using Composer" and "Autoloading". Did you follow the procedures in your code?

Publishing site created with Laravel error

Hi there i follow this tutorial how to setup on the FreeWebHostingArea com :
If your domain is pointed to public_html directory then all content should placed in that directory. How ? let me tell you
Copy all files and folders ( including public folder ) in public html
Copy all content of public folder and paste it in document root ( i.e.
public_html ) Remove the public folder Open your bootstrap/paths.php
and then changed 'public' => DIR.'/../public', into 'public' =>
DIR.'/..',
and finally in index.php,
Change
require DIR.'/../bootstrap/autoload.php';
$app = require_once DIR.'/../bootstrap/start.php'; into
require DIR.'/bootstrap/autoload.php';
$app = require_once DIR.'/bootstrap/start.php';
but when i load the index i get this error
Fatal error: require(): Failed opening required
'/home/vhosts/epernikhardware.eu5.org/vendor/composer/autoload_files.php'
(include_path='/home/vhosts/epernikhardware.eu5.org/vendor/phpseclib/phpseclib/phpseclib:.:/usr/share/pear:/usr/share/php')
in
/home/vhosts/epernikhardware.eu5.org/vendor/composer/autoload_real.php
on line 47
And can amy one explain me how to easily get this simple site to work is it so hard to publish a few web pages with laravel framework. Please help
I don't know about that hosting but for other hosting service such as JustHost, GoDaddy, BlueHost, HostGator... I deploy the Laravel web pretty much easy.
1) Access to the host via SSH, get the source code
$ cd www/
$ git clone https://github.com/ME/MY-PROJECT.git .
2) Get Composer:
$ curl -sS https://getcomposer.org/installer | php -- --filename=composer
3) Update all dependencies (/vendor)
$ composer update
4) Move the /public/.htaccess to the root
$ mv public/.htaccess .
That's all, site is ready. Perhaps, there are more steps in configuring the database but it is not necessary to mention here.
If you host your site on Forge or DigitalOcean, the process would be much easy, just add the source origin, and most of things will be done automatically.
Make sure the PHP version in your computer and the PHP version in the cpanel of your hosting site is the same. I also had the same problem and this helped me.

Resources