PHPUnit Boilerplate

Hits: 118

Of course first  phpunit/phpunit to be installed. I think, local installation much better.

composer require --dev phpunit/phpunit ^7

# phpunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false">
    <testsuites>
        <testsuite name="Unit">
            <directory suffix="Test.php">./tests</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./src</directory>
        </whitelist>
    </filter>
</phpunit>

# ExampleTest.php, this file must be under tests folder.

(root/tests/ExampleTest.php)

?php
namespace yourvendorname\yourpackagename;
use PHPUnit\Framework\TestCase;

/**
 * Description of ExampleTest
 *
 * @author Koray Zorluoglu <koray@d8devs.com>
 */
class ExampleTest extends TestCase
{

    public function testExampleMethod()
    {
        $count = 0;
        $this->assertSame(0, $count);
    }

}

# Run on Command prompt.

./vendor/bin/phpunit

# Example Output

$ ./vendor/bin/phpunit
PHPUnit 7.4.5 by Sebastian Bergmann and contributors.

....                                                                4 / 4 (100%)

Time: 968 ms, Memory: 4.00MB

OK (4 tests, 4 assertions)

 

Social Poster – A Simple Facebook Page and Twitter poster

Hits: 191

Social (Media) Poster

Social Poster is a simple Facebook Page and Twitt poster

  • Text Posting
  • Text with Image-\s Posting

Tech

Social Poster uses a number of open source projects to work properly:

  • facebook/graph-sdk – Facebook SDK for PHP (v5)
  • dg/twitter-php – Twitter for PHP is a very small and easy-to-use library for sending messages to Twitter and receiving status updates.
  • dillinger.io – Markdown editor for this readme.md creating/editing. Fast and easy to extend.
  • Twitter Bootstrap – great UI boilerplate for modern web apps
  • jQuery – duh

Integration

Facebook

  • Create Facebook Developer Account
  • Create Simple App
    • You not need Facebook Products other anything under Your App Settings, I have only Contact E-mail filled
    • Call https://developers.facebook.com/tools/explorer/
    • Select Your App under Application Select
    • Select Page Access Token under Get Token Button
    • Click i icon after Access Token Creating
    • Click Open in Access Token Tool from opened Internal Popup
    • Click Generate Long Lived Token

Twitter

  • Create Twitter Developer Account
  • Create Simple App
    • Click App Details
    • This Keys will be located under Keys and tokens Menu

My Experiences with Laravel 5.5

Hits: 358

  1. First Project / Look : I have had some experience in module writing my company software solution for an Aid Organization. This project was with Laravel 5.1, what the customer wants as a correction or update…
    1. What have I had?
      1. First of all, some pre-installed plugins(from the old developer at company) need to be updated, because these plugins work not nicely or stable.. But isn’t possible, because XYZ Plugin needed higher version another ABC, DEF Plugins, this plugin needed higher version of laravel/framework.  If I framework updated, then you get several errors, because main core functions or classes changed or removed…
    2. Results
      1. My Idea: Bad/Unstable Relase Management.
        1. Solution 1: Dear Customer, these corrections not possible.
        2. Solution 2 : Writing/Modifying  with hand these Plugin Packages.
  2. Second Project : I have developed a Member and SMS Management Software with Laravel 5.5.
    1. What have I had?
      1. Creating a class and setting up Database Tables is very easy, with php artisan command you can easily insert or execute several things. For example:
        php artisan make:controller HomeController --resource

        then this command generated  a controller with CRUD Methods at app/Http/Controllers/HomeController.php.

      2. Mailable Class, Another useful and clean thing.
      3. Eloquent ORM, simple ActiveRecord implementation.
      4. Blade Templating Engine, simple templating engine.
    2. Results:
      1. My Idea: Good for new starting a new Project.
        1. but you need to update at any time, otherwise you have to develop again a project.

Last of all: Good for new Starting a new project, but you have to update at any time. If you can’t do that, choose another Frameworks.

Raspberry Pi Zero W + USB Modem – SMS Gateway

Hits: 737

This Article updated on 08.09.2019

Install usb-modeswitch, smstools, wvdial

sudo apt-get install usb-modeswitch usb-modeswitch-data smstools wvdial

Find right device and baudrate with this command;

sudo wvdialconf

…my modem information (modem on ttyUSB1 and baudrate 9600)…

ttyUSB0<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB0<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB0<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
ttyUSB1<*1>: ATQ0 V1 E1 -- OK
ttyUSB1<*1>: ATQ0 V1 E1 Z -- OK
ttyUSB1<*1>: ATQ0 V1 E1 S0=0 -- ERROR
ttyUSB1<*1>: ATQ0 V1 E1 &C1 -- ERROR
ttyUSB1<*1>: ATQ0 V1 E1 &D2 -- ERROR
ttyUSB1<*1>: ATQ0 V1 E1 +FCLASS=0 -- OK
ttyUSB1<*1>: Modem Identifier: ATI -- Manufacturer: ZTE INCORPORATED
ttyUSB1<*1>: Speed 9600: AT -- OK
ttyUSB1<*1>: Max speed is 9600; that should be safe.
ttyUSB1<*1>: ATQ0 V1 E1 +FCLASS=0 -- OK
ttyUSB2<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB2<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB2<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
ttyUSB3<*1>: ATQ0 V1 E1 -- OK
ttyUSB3<*1>: ATQ0 V1 E1 Z -- OK
ttyUSB3<*1>: ATQ0 V1 E1 S0=0 -- ERROR
ttyUSB3<*1>: ATQ0 V1 E1 &C1 -- ERROR
ttyUSB3<*1>: ATQ0 V1 E1 &D2 -- ERROR
ttyUSB3<*1>: ATQ0 V1 E1 +FCLASS=0 -- OK
ttyUSB3<*1>: Modem Identifier: ATI -- Manufacturer: ZTE INCORPORATED
ttyUSB3<*1>: Speed 9600: AT -- OK
ttyUSB3<*1>: Max speed is 9600; that should be safe.
ttyUSB3<*1>: ATQ0 V1 E1 +FCLASS=0 -- OK

Found a modem on /dev/ttyUSB1.
Modem configuration written to /etc/wvdial.conf.
ttyUSB1<Info>: Speed 9600; init "ATQ0 V1 E1 +FCLASS=0"
ttyUSB3<Info>: Speed 9600; init "ATQ0 V1 E1 +FCLASS=0"

Modify your smsd.conf

sudo nano /etc/smsd.conf

my smsd.conf with founded Modem information like:

devices = GSM1
outgoing = /var/www/sms/outbox
checked = /var/www/sms/checked
incoming = /var/www/sms/inbox
logfile = /var/log/smstools/smsd.log
infofile = /var/run/smstools/smsd.working
pidfile = /var/run/smstools/smsd.pid
outgoing = /var/www/sms/outbox

checked = /var/www/sms/checked
failed = /var/www/sms/error
incoming = /var/www/sms/inbox
sent = /var/www/sms/sent
stats = /var/log/smstools/smsd_stats

[GSM1]
#init =
device = /dev/ttyUSB1
incoming = yes
pin = 1234
baudrate = 9600

Create Directory for SMS Sending

sudo mkdir /var/www/sms
sudo mkdir /var/www/sms/inbox
sudo mkdir /var/www/sms/outbox
sudo mkdir /var/www/sms/error
sudo mkdir /var/www/sms/sent
sudo mkdir /var/www/sms/checked
sudo chmod -R 0777 /var/www/sms/

Restart then smstools3

sudo /etc/init.d/smstools restart

For Testing Create a file under /var/spool/sms/outgoing/ Folder. I create like:

echo -e "To: 00491111111111\n\nTest SMS" > /var/www/sms/outbox/testsms.txt

Server configuration and php works coming soon!

sudo mkdir /var/www/sms
sudo mkdir /var/www/sms/inbox
sudo mkdir /var/www/sms/outbox
sudo mkdir /var/www/sms/error
sudo mkdir /var/www/sms/sent
sudo mkdir /var/www/sms/checked
sudo chmod -R 0777 /var/www/sms/